|
Boost : |
Subject: Re: [boost] New dependency report
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2014-06-07 13:25:29
On Saturday 07 June 2014 18:46:19 Peter Dimov wrote:
>
> 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.
>
> 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();
> }
It's still a partial solution since
f(is_pointer< int >::type());
is also valid with the current implementation. We can add the conversion
constructor to mpl::bool_ but that is not a replacement for the current
mechanism, at least not a backward compatible one.
I think our previous plan with TypeTraits.Core is better. Pulling type traits
to Core doesn't sound good, it's better to create a separate submodule for it.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk