Boost logo

Boost Users :

Subject: [Boost-users] [utility] BOOST_IDENTITY_TYPE drops const-ness of value types
From: Nick Stokes (randomaccessiterator_at_[hidden])
Date: 2016-04-29 11:30:13

Looks like const value types, once passed thru BOOST_IDENTITY_TYPE,
"becomes" non-const. Like so:

// Attempt to implement a multi-argument utility macro, where arguments are
// types, parenthesized only when required (by the user, when type has
#define ASSERT_EQUAL( t1, t2 ) \
   static_assert( std::is_same< \
>::value, #t1 " not same as " #t2)

// sanity check: static_asserts as expected
ASSERT_EQUAL( int, double );

// sanity check: static_assert as expected for types with commas
ASSERT_EQUAL( (std::pair<int, double>), (std::pair<double, int>) );

// Here is the failure: this is expected to assert but it doesnt!
ASSERT_EQUAL( const int, int );

>From the implementation of BOOST_IDENTITY_TYPE, it is clear why this is
happening, as the function signature is independent of const-ness of value

Is this a bug? Or is this not the way BOOST_IDENTITY_TYPE is supposed to
be used?


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at