Boost logo

Boost Users :

Subject: Re: [Boost-users] detect if a type has a size_t member
From: Hicham Mouline (hicham_at_[hidden])
Date: 2009-07-29 10:16:46


> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of Mathias Gaunard
> Sent: 29 July 2009 13:12
> To: boost-users_at_[hidden]
> Subject: Re: [Boost-users] detect if a type has a size_t member
>
> Hicham Mouline wrote:
>
> >> BOOST_HAS_MEMBER_DATA(size_t, maxsize);
> >>
> >>
> >> int main()
> >> {
> >> if ( boost::introspection::has_member_data_maxsize<T>::value )
> >> {
> >> std::cout<<" T has max_size"<<std::endl;
> >> }
> >> return 0;
> >> }
> > Thank you,
> >
> > 1) struct S {
> > static const size_t maxsize =5;
> > };
> >
> > 2) struct S {
> > static size_t maxsize;
> > };
> >
> > 3) struct S {
> > size_t maxsize;
> > };
> >
> >
> > Applied to S, the code doesn't compile in 1 and returns false in 2.
> >
> > Is there a fix that can make it work for 1, 2 and 3 ?
>
> No.
> Static members and non-static ones are very different things, and each
> requires usage of a different macro.
> BOOST_HAS_STATIC_MEMBER_DATA and BOOST_HAS_MEMBER_DATA.

I can't find BOOST_HAS_STATIC_MEMBER_DATA in introspection in the sandbox.
Were you referring to some header files elsewhere?

Joel, re compiler, I am using vs2005.

The case I really need is 1... so I need to detect the compile-time static
constant,
and not a variable member... so is there a way to do it?

Rds,


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net