Boost logo

Boost :

Subject: [boost] BOOST_STATIC_CONSTANT
From: Vladimir Batov (Vladimir.Batov_at_[hidden])
Date: 2017-08-16 23:22:14


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?!


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