|
Boost : |
Subject: Re: [boost] [type_traits] Rewrite and dependency free version
From: Peter Dimov (lists_at_[hidden])
Date: 2015-01-14 19:51:44
John Maddock wrote:
> I'm going to throw this out there to see what folks think:
They very much approve of, and thank you for, your work. :-) This is so much
better. :-)
> 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:
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 one).
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