« Return to Thread: detect if a type has a size_t member

Re: detect if a type has a size_t member

by Mathias Gaunard-2 :: Rate this Message:

Reply to Author | View in Thread

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.


_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

 « Return to Thread: detect if a type has a size_t member