El 07/06/2014 17:37, Vicente J. Botet Escriba escribió:
To be standard conforming, we would need to add "std::integral_constant
" as "type" member. But IMHO this seems a bit redundant. Well, currently something more
template
struct integral_constant { static constexpr T value = v; typedef T value_type; typedef integral_constant
type; constexpr operator value_type() const { return value; } constexpr value_type operator()() const { return value; } };
Vicente C++ International Standard
Yes. The issue is not about deriving from integral_constant if it's a very simple header with no dependencies. Currently if deriving from integral_constant: 1) We need to depend on another Boost library (type_traits and its dependencies, boost::integral_constant derives from mpl::integral_c so we start adding dependencies) 2) In C++11 compilers we need to choose between boost::integral_constant or std::integral_constant. A standard conforming trait is not convertible to boost::true_type. On the other hand: static const bool value = true/false seems very lightweight and portable. An alternative is to inject std::integral_constant into the boost namespace or derive boost::integral_constant from std::integral_constant if it adds more operations. If integral_constant is needed to define a simple trait, then integral_constant should be: - compatible with C++11. - extremely simple, without any further dependencies, and live in core (not in type_traits, mpl or any other library). Just my 2 cents, Ion