Subject: Re: [boost] [type_traits] Rewrite and dependency free version
From: John Maddock (boost.regex_at_[hidden])
Date: 2015-01-15 04:00:37
>> In a branch called "Version2", see
>> https://github.com/boostorg/type_traits/tree/Version2 is a partially
>> rewritten type_traits lib: it doesn't yet contain all the traits of
>> the old one, but there's a pretty good selection to test.
> I wonder why you have decided to return a reference to mpl::bool_,
> instead of just ("stupidly") returning by value. Compilers like "stupid"
> code, they optimize it better. Typically, the use case is:
It was the only way to break the dependency to MPL (without modifying
MPL that is). Can't return a forward declaration by value...
> void f( mpl::true_ );
> void f( mpl::false_ );
> f( is_pointer<X>() );
> and if you return by value, it can construct directly into the argument,
> whereas by reference it needs to use the copy constructor.
> That said, I still think that it may be better to add the conversion on
> the MPL side; this will obviate the need for the fragile forward
> declarations (and it will support any integral constants, not just this
> We can, of course, in addition add a converting constructor to
> integral_constant as well, so that the "officially blessed" way to
> dispatch would be on true_type and false_type. This dispatch will work
> on std:: traits as well.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk