Re: [Algorithms] Complexity of new hardware
Brought to you by:
vexxed72
|
From: Jon W. <jw...@gm...> - 2009-04-21 00:42:08
|
Will Vale wrote:
> On Tue, 21 Apr 2009 04:55:20 +1200, Jon Watte <jw...@gm...> 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
|