mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
fix container_traits const-qualified specialization
This commit is contained in:
parent
64b422546e
commit
d4f7fa9b9c
4 changed files with 64 additions and 27 deletions
|
@ -22,6 +22,7 @@ namespace sprout {
|
||||||
// inherit_if_size_type
|
// inherit_if_size_type
|
||||||
// inherit_if_difference_type
|
// inherit_if_difference_type
|
||||||
// inherit_if_pointer
|
// inherit_if_pointer
|
||||||
|
// inherit_if_const_pointer
|
||||||
// inherit_if_static_size
|
// inherit_if_static_size
|
||||||
//
|
//
|
||||||
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(value_type);
|
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(value_type);
|
||||||
|
@ -40,6 +41,18 @@ namespace sprout {
|
||||||
//
|
//
|
||||||
SPROUT_HAS_XXX_VALUE_DEF_LAZY(static_size);
|
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>
|
template<typename Container, typename Enable = void>
|
||||||
struct inherit_if_fixed_size {};
|
struct inherit_if_fixed_size {};
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
|
@ -53,6 +66,9 @@ namespace sprout {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// container_traits_default
|
||||||
|
//
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
struct container_traits_default
|
struct container_traits_default
|
||||||
: public sprout::detail::inherit_if_value_type<Container>
|
: public sprout::detail::inherit_if_value_type<Container>
|
||||||
|
@ -86,6 +102,24 @@ namespace sprout {
|
||||||
return static_size;
|
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
|
} // namespace detail
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -97,13 +131,8 @@ namespace sprout {
|
||||||
{};
|
{};
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
struct container_traits<Container const>
|
struct container_traits<Container const>
|
||||||
: public sprout::container_traits<Container>
|
: public sprout::detail::container_traits_const_default<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;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T, std::size_t N>
|
template<typename T, std::size_t N>
|
||||||
struct container_traits<T[N]>
|
struct container_traits<T[N]>
|
||||||
|
@ -111,13 +140,8 @@ namespace sprout {
|
||||||
{};
|
{};
|
||||||
template<typename T, std::size_t N>
|
template<typename T, std::size_t N>
|
||||||
struct container_traits<T const[N]>
|
struct container_traits<T const[N]>
|
||||||
: public sprout::container_traits<T[N]>
|
: public sprout::detail::container_traits_const_default<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;
|
|
||||||
};
|
|
||||||
} // namespace sprout
|
} // namespace sprout
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_CONTAINER_CONTAINER_TRAITS_HPP
|
#endif // #ifndef SPROUT_CONTAINER_CONTAINER_TRAITS_HPP
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/math/fpclassify.hpp>
|
#include <sprout/math/fpclassify.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isfinite.hpp>
|
||||||
#include <sprout/math/isinf.hpp>
|
#include <sprout/math/isinf.hpp>
|
||||||
|
#include <sprout/math/isnan.hpp>
|
||||||
|
#include <sprout/math/isnormal.hpp>
|
||||||
#include <sprout/math/iszero.hpp>
|
#include <sprout/math/iszero.hpp>
|
||||||
#include <sprout/math/issubnormal.hpp>
|
#include <sprout/math/issubnormal.hpp>
|
||||||
#include <sprout/math/isnormal.hpp>
|
|
||||||
#include <sprout/math/isfinite.hpp>
|
|
||||||
#include <sprout/math/signbit.hpp>
|
#include <sprout/math/signbit.hpp>
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_MATH_CLASSIFICATIONS_HPP
|
#endif // #ifndef SPROUT_MATH_CLASSIFICATIONS_HPP
|
||||||
|
|
|
@ -2,11 +2,12 @@
|
||||||
#define SPROUT_MATH_FUNCTIONS_HPP
|
#define SPROUT_MATH_FUNCTIONS_HPP
|
||||||
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/math/operations.hpp>
|
#include <sprout/math/classifications.hpp>
|
||||||
#include <sprout/math/exponential.hpp>
|
|
||||||
#include <sprout/math/power.hpp>
|
|
||||||
#include <sprout/math/trigonometric.hpp>
|
#include <sprout/math/trigonometric.hpp>
|
||||||
#include <sprout/math/hyperbolic.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
|
#endif // #ifndef SPROUT_MATH_FUNCTIONS_HPP
|
||||||
|
|
|
@ -7,9 +7,10 @@
|
||||||
#include <sprout/type_traits/has_xxx.hpp>
|
#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); \
|
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> \
|
template<typename T, typename Enable = void> \
|
||||||
struct NAME {}; \
|
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 \
|
typename std::enable_if<SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_inherit_if_xxx_type_def_impl_has_, TYPE), __LINE__)<T>::value>::type \
|
||||||
> { \
|
> { \
|
||||||
public: \
|
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
|
// 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) \
|
#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_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); \
|
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> \
|
template<typename T, typename Enable = void> \
|
||||||
struct NAME {}; \
|
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 \
|
typename std::enable_if<SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_inherit_if_xxx_constant_def_impl_has_, CONSTANT), __LINE__)<T>::value>::type \
|
||||||
> { \
|
> { \
|
||||||
public: \
|
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
|
// 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) \
|
#define SPROUT_INHERIT_IF_XXX_CONSTANT_DEF_LAZY(CONSTANT) \
|
||||||
SPROUT_INHERIT_IF_XXX_CONSTANT_DEF(SPROUT_PP_CAT(inherit_if_, CONSTANT), CONSTANT)
|
SPROUT_INHERIT_IF_XXX_CONSTANT_DEF(SPROUT_PP_CAT(inherit_if_, CONSTANT), CONSTANT)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue