John Maddock wrote:
In fact in C++11 it makes sense to me have:
namespace boost{ namespace mpl{
template <bool b>
using bool_ = std::integral_constant;
I have another solution, which appears good enough to go into Core. We could
also enhance mpl::bool_ in the same way. Note that the trait knows nothing
about bool_, but dispatch still works.
#include
#include
//
template< bool V > struct bool_
{
BOOST_STATIC_CONSTANT( bool, value = V );
template< class T > bool_( T const &, typename boost::enable_if_c<
T::value == V >::type * = 0 )
{
}
};
typedef bool_< false > false_;
typedef bool_< true > true_;
//
#include
template< class T > struct is_pointer
{
BOOST_STATIC_CONSTANT( bool, value = false );
};
template< class T > struct is_pointer< T* >
{
BOOST_STATIC_CONSTANT( bool, value = true );
};
int f( true_ )
{
return 5;
}
int f( false_ )
{
return 11;
}
int main()
{
BOOST_TEST( f( is_pointer< int* >() ) == 5 );
BOOST_TEST( f( is_pointer< int >() ) == 11 );
return boost::report_errors();
}