Boost logo

Boost :

Subject: Re: [boost] BOOST_STATIC_CONSTANT
From: Edward Diener (eldiener_at_[hidden])
Date: 2017-08-17 02:26:23


On 8/16/2017 7:22 PM, Vladimir Batov via Boost wrote:
> There is something seemingly basic that puzzles me greatly. I am hoping
> people might clarify something I totally fail to understand.
>
> I've been using BOOST_STATIC_CONSTANT for ages (with GCC). Now I have
> something seemingly non-controversial:
>
> template<typename user_type>
> struct impl_ptr
> {
> using yes_type = boost::type_traits::yes_type;
> using no_type = boost::type_traits::no_type;
> using ptr_type = typename std::remove_const<user_type>::type*;
>
> template<typename Y>
> static yes_type test (Y*, typename Y::impl_ptr_type* =nullptr);
> static no_type test (...);
>
> BOOST_STATIC_CONSTANT(bool, value = (1 ==
> sizeof(test(ptr_type(nullptr)))));
> };
>
> When compiled with gcc-.5.4.0, both lines below pass:
>
> BOOST_TEST(true == boost::impl_ptr<Shared>::value);
> BOOST_TEST(true == boost::impl_ptr<Shared const>::value);
>
> The only difference between them is "const". However, when I compile
> with clang-4.0, the second (const) line passes. However, the first one
> fails! I refuse to believe it's a clang glitch. It must be me doing
> something really stupid. Help?!

Can you not use tti to do what you want to do ?


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