Boost logo

Boost :

Subject: Re: [boost] [any] new version
From: Emil Dotchevski (emil_at_[hidden])
Date: 2011-08-31 21:26:37


On Wed, Aug 31, 2011 at 5:55 PM, Ilya Bobir <ilya.bobir_at_[hidden]> wrote:
> On Wed, Aug 31, 2011 at 5:16 PM, Martin Bidlingmaier
> <Martin.Bidlingmaier_at_[hidden]> wrote:
>> Hi,
>>
>> [...] It does not depend on rtti and uses a static integer value instead of std::type_info to store type information.
>> [...]
>
> Quote from any.hpp:
>
>    //use static class member to force initialization at program start
> to make type_id thread safe (and more efficient)
>    template< class T >
>    class type_id
>    {
>    public:
>        static unsigned int value;
>    };
>    template< class T >
>    unsigned int type_id< T >::value = next_id();
>
> I do not think you can initialize a class static in a header.  If you
> include any.hpp in more than one cpp you will have the same static
> been initialized more than once.
> MS C++ linker complains.  Though the standard requires no diagnostic.
> See "9.4.2 Static data members" paragraph 5.

In addition, in general, the initialization of statics and globals may
be postponed until after main() is entered.

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk