Boost logo

Boost :

Subject: Re: [boost] New dependency report
From: John Maddock (boost.regex_at_[hidden])
Date: 2014-06-07 04:19:31


On 06/06/2014 22:40, Peter Dimov wrote:
> John Maddock wrote:
>> I'm tied of saying this.... but if mpl::bool_ and int_ were moved out
>> of MPL full, either to core, or to some mpl_core, then there's no need
>> to split type_traits anymore.
>
> The question is: what is the minimal conforming implementation of a type
> trait? Is it
>
> template<class T> struct something
> {
> bool const value = false;
> }
>
> or is it, instead,
>
> template<class T> struct something: mpl::false_
> {
> };
>
> For C++11, the answer to this question determines whether the std type
> traits are conforming type traits for us. In other words, whether "using
> std::is_pointer;" is a conforming implementation of boost::is_pointer.
>
> For C++03, the answer determines whether I can specialize a type trait
> for my type without including the header that defines mpl::true_ and
> mpl::false_.
>
> I prefer the first definition for reasons already stated. This doesn't
> mean however that going with the second, along with a lean and mean
> mpl::bool_, will not going to be a considerable improvement as well. Far
> from it.

For me it seems there are relatively few uses of type_traits that don't
end up requiring either mpl::if_ or mpl::bool_ anyway?

>> Indeed I suspect there's a huge amount of obfuscated code inherited
>> from mpl's broken-compiler-workarounds that can now be removed: not
>> only do we not support those compilers any more, but given that they
>> haven't been tested in heaven knows how long they're unlikely to
>> compile *any* of modern Boost anyway.
>
> That's certainly true. If we remove the obsolete workarounds from MPL
> and TypeTraits things will start looking much better.
>
>> In fact in C++11 it makes sense to me have:
>>
>> namespace boost{ namespace mpl{
>>
>> template <bool b>
>> using bool_ = std::integral_constant<bool, b>;
>
> Interesting. This makes the std type traits conform to my second
> definition above, so that "using std::is_member_pointer;" (say) is a
> legitimate implementation of boost::is_member_pointer even when
> derivation from mpl::bool_ is required.
>
> I'm not sure that this is a conforming mpl::bool_ though. It almost is.
> But mpl integral constants need to have a nested ::tag (integral_c_tag),
> and std::integral_constant doesn't have one. Maybe this requirement can
> be dropped. Maybe it can't. I don't know.

Ah, good point, clearly we can't do that then.

John.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk