Boost logo

Boost :

Subject: Re: [boost] [any] new version
From: Ilya Bobir (ilya.bobir_at_[hidden])
Date: 2011-08-31 20:55:11


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.

Ilya Bobyr


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