Re: Complexity of new hardware

Jon Watte <[email protected]>
Newsgroups gmane.games.devel.algorithms
Message-ID <[email protected]>
Will Vale wrote:
> On Tue, 21 Apr 2009 04:55:20 +1200, Jon Watte <[email protected]> wrote:
>   
>> You can actually use some template trickery to hoist the RTTI() /
>> MEMBER() parts into the struct itself.
>>     
>
> I think that's pretty neat, but it only moves, rather than removes the  
> duplication, although I can see that it's easier to verify in one place  
> like that. (I also needed to add an implementation to the cpp file to  
> provide storage for foo::_theInfo to get it to link under VC9.)
>
> It also generates code-to-generate-data rather than data, which was  
> something I was keen to avoid as much as possible. That said, if you  
>   


Sorry, the _theInfo can be wrapped as a static singleton in a static 
inline function, and then it will link with VC as well.

I don't actually generate (much) code to generate data, although I 
suppose the constructors do count. It all gets run at static init AFAICT.

The edit for VC++:

  static _info<T> _theInfo;
  static inline _info<T>  &info() {
    return _theInfo;
  }

turns into:

  static inline _info<T>  &info() {
    static _info<T> _theInfo;
    return _theInfo;
  }

Toggling two lines can make all the difference in the world :-)

(And I suppose I could even use the instance() template that automates 
this pattern)

Sincerely,

jw


------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
GDAlgorithms-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.