fix container_traits const-qualified specialization

This commit is contained in:
bolero-MURAKAMI 2012-05-11 09:23:01 +09:00
parent 64b422546e
commit d4f7fa9b9c
4 changed files with 64 additions and 27 deletions

View file

@ -22,6 +22,7 @@ namespace sprout {
// inherit_if_size_type
// inherit_if_difference_type
// inherit_if_pointer
// inherit_if_const_pointer
// inherit_if_static_size
//
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(value_type);
@ -40,6 +41,18 @@ namespace sprout {
//
SPROUT_HAS_XXX_VALUE_DEF_LAZY(static_size);
//
// inherit_iterator_if_const_iterator
// inherit_reference_if_const_reference
// inherit_pointer_if_const_pointer
//
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(iterator, const_iterator);
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(reference, const_reference);
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(pointer, const_pointer);
//
// inherit_if_fixed_size
//
template<typename Container, typename Enable = void>
struct inherit_if_fixed_size {};
template<typename Container>
@ -53,6 +66,9 @@ namespace sprout {
}
};
//
// container_traits_default
//
template<typename Container>
struct container_traits_default
: public sprout::detail::inherit_if_value_type<Container>
@ -86,6 +102,24 @@ namespace sprout {
return static_size;
}
};
//
// container_traits_const_default
//
template<typename Container>
struct container_traits_const_default
: public sprout::detail::inherit_if_value_type<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_const_iterator<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_const_reference<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_size_type<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_difference_type<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_const_pointer<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_static_size<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_fixed_size<sprout::container_traits<Container> >
, public sprout::detail::inherit_iterator_if_const_iterator<sprout::container_traits<Container> >
, public sprout::detail::inherit_reference_if_const_reference<sprout::container_traits<Container> >
, public sprout::detail::inherit_pointer_if_const_pointer<sprout::container_traits<Container> >
{};
} // namespace detail
//
@ -97,13 +131,8 @@ namespace sprout {
{};
template<typename Container>
struct container_traits<Container const>
: public sprout::container_traits<Container>
{
public:
typedef typename sprout::container_traits<Container>::const_iterator iterator;
typedef typename sprout::container_traits<Container>::const_reference reference;
typedef typename sprout::container_traits<Container>::const_pointer pointer;
};
: public sprout::detail::container_traits_const_default<Container>
{};
template<typename T, std::size_t N>
struct container_traits<T[N]>
@ -111,13 +140,8 @@ namespace sprout {
{};
template<typename T, std::size_t N>
struct container_traits<T const[N]>
: public sprout::container_traits<T[N]>
{
public:
typedef typename sprout::container_traits<T[N]>::const_iterator iterator;
typedef typename sprout::container_traits<T[N]>::const_reference reference;
typedef typename sprout::container_traits<T[N]>::const_pointer pointer;
};
: public sprout::detail::container_traits_const_default<T[N]>
{};
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_CONTAINER_TRAITS_HPP

View file

@ -3,12 +3,12 @@
#include <sprout/config.hpp>
#include <sprout/math/fpclassify.hpp>
#include <sprout/math/isnan.hpp>
#include <sprout/math/isfinite.hpp>
#include <sprout/math/isinf.hpp>
#include <sprout/math/isnan.hpp>
#include <sprout/math/isnormal.hpp>
#include <sprout/math/iszero.hpp>
#include <sprout/math/issubnormal.hpp>
#include <sprout/math/isnormal.hpp>
#include <sprout/math/isfinite.hpp>
#include <sprout/math/signbit.hpp>
#endif // #ifndef SPROUT_MATH_CLASSIFICATIONS_HPP

View file

@ -2,11 +2,12 @@
#define SPROUT_MATH_FUNCTIONS_HPP
#include <sprout/config.hpp>
#include <sprout/math/operations.hpp>
#include <sprout/math/exponential.hpp>
#include <sprout/math/power.hpp>
#include <sprout/math/classifications.hpp>
#include <sprout/math/trigonometric.hpp>
#include <sprout/math/hyperbolic.hpp>
#include <sprout/math/classifications.hpp>
#include <sprout/math/exponential.hpp>
#include <sprout/math/power.hpp>
#include <sprout/math/operations.hpp>
#include <sprout/math/factorial.hpp>
#endif // #ifndef SPROUT_MATH_FUNCTIONS_HPP

View file

@ -7,9 +7,10 @@
#include <sprout/type_traits/has_xxx.hpp>
//
// SPROUT_INHERIT_IF_XXX_TYPE_DEF
// SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF
// SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY
//
#define SPROUT_INHERIT_IF_XXX_TYPE_DEF(NAME, TYPE) \
#define SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF(NAME, ALIAS, TYPE) \
SPROUT_HAS_XXX_TYPE_DEF(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_inherit_if_xxx_type_def_impl_has_, TYPE), __LINE__), TYPE); \
template<typename T, typename Enable = void> \
struct NAME {}; \
@ -19,19 +20,25 @@
typename std::enable_if<SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_inherit_if_xxx_type_def_impl_has_, TYPE), __LINE__)<T>::value>::type \
> { \
public: \
typedef typename T::TYPE TYPE; \
typedef typename T::TYPE ALIAS; \
}
#define SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(ALIAS, TYPE) \
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF(SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(inherit_, ALIAS), _if_), TYPE), ALIAS, TYPE)
//
// SPROUT_INHERIT_IF_XXX_TYPE_DEF
// SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY
//
#define SPROUT_INHERIT_IF_XXX_TYPE_DEF(NAME, TYPE) \
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF(NAME, TYPE, TYPE)
#define SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(TYPE) \
SPROUT_INHERIT_IF_XXX_TYPE_DEF(SPROUT_PP_CAT(inherit_if_, TYPE), TYPE)
//
// SPROUT_INHERIT_IF_XXX_CONSTANT_DEF
// SPROUT_INHERIT_ALIAS_IF_XXX_CONSTANT_DEF
// SPROUT_INHERIT_ALIAS_IF_XXX_CONSTANT_DEF_LAZY
//
#define SPROUT_INHERIT_IF_XXX_CONSTANT_DEF(NAME, CONSTANT) \
#define SPROUT_INHERIT_ALIAS_IF_XXX_CONSTANT_DEF(NAME, ALIAS, CONSTANT) \
SPROUT_HAS_XXX_VALUE_DEF(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_inherit_if_xxx_constant_def_impl_has_, CONSTANT), __LINE__), CONSTANT); \
template<typename T, typename Enable = void> \
struct NAME {}; \
@ -41,12 +48,17 @@
typename std::enable_if<SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_inherit_if_xxx_constant_def_impl_has_, CONSTANT), __LINE__)<T>::value>::type \
> { \
public: \
SPROUT_STATIC_CONSTEXPR decltype(T::CONSTANT) CONSTANT = T::CONSTANT; \
SPROUT_STATIC_CONSTEXPR decltype(T::CONSTANT) ALIAS = T::CONSTANT; \
}
#define SPROUT_INHERIT_ALIAS_IF_XXX_CONSTANT_DEF_LAZY(ALIAS, CONSTANT) \
SPROUT_INHERIT_ALIAS_IF_XXX_CONSTANT_DEF(SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(inherit_, ALIAS), _if_), CONSTANT), ALIAS, CONSTANT)
//
// SPROUT_INHERIT_IF_XXX_CONSTANT_DEF
// SPROUT_INHERIT_IF_XXX_CONSTANT_DEF_LAZY
//
#define SPROUT_INHERIT_IF_XXX_CONSTANT_DEF(NAME, CONSTANT) \
SPROUT_INHERIT_ALIAS_IF_XXX_CONSTANT_DEF(NAME, CONSTANT, CONSTANT)
#define SPROUT_INHERIT_IF_XXX_CONSTANT_DEF_LAZY(CONSTANT) \
SPROUT_INHERIT_IF_XXX_CONSTANT_DEF(SPROUT_PP_CAT(inherit_if_, CONSTANT), CONSTANT)