From 7e709630c62ff15748287d2327844edf90382568 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Sat, 15 Mar 2014 12:06:51 +0900 Subject: [PATCH] rename type_traits is_int -> is_sint add new type_traits is_*_unqualified --- sprout/compost/formats/as_pcm_wave.hpp | 4 +- sprout/detail/math/int.hpp | 4 +- sprout/detail/pow.hpp | 4 +- sprout/functional/bind/bind.hpp | 25 +++++------ sprout/generator/generator_access_traits.hpp | 8 ++-- sprout/math/factorial.hpp | 26 ++++++------ sprout/random/type_traits.hpp | 41 +++++++++++++++++++ sprout/type_traits.hpp | 5 ++- sprout/type_traits/is_const_unqualified.hpp | 28 +++++++++++++ sprout/type_traits/is_cv_unqualified.hpp | 29 +++++++++++++ .../type_traits/{is_int.hpp => is_sint.hpp} | 12 +++--- .../type_traits/is_volatile_unqualified.hpp | 28 +++++++++++++ 12 files changed, 172 insertions(+), 42 deletions(-) create mode 100644 sprout/type_traits/is_const_unqualified.hpp create mode 100644 sprout/type_traits/is_cv_unqualified.hpp rename sprout/type_traits/{is_int.hpp => is_sint.hpp} (76%) create mode 100644 sprout/type_traits/is_volatile_unqualified.hpp diff --git a/sprout/compost/formats/as_pcm_wave.hpp b/sprout/compost/formats/as_pcm_wave.hpp index 0f11219f..f282fb91 100644 --- a/sprout/compost/formats/as_pcm_wave.hpp +++ b/sprout/compost/formats/as_pcm_wave.hpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include @@ -26,7 +26,7 @@ namespace sprout { template struct normalized_to_pcm_wave< IntType, - typename std::enable_if::value>::type + typename std::enable_if::value>::type > { public: typedef IntType result_type; diff --git a/sprout/detail/math/int.hpp b/sprout/detail/math/int.hpp index 8ffecb9b..c5e20f33 100644 --- a/sprout/detail/math/int.hpp +++ b/sprout/detail/math/int.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include namespace sprout { @@ -56,7 +56,7 @@ namespace sprout { // template< int Base = 10, typename IntType, - typename sprout::enabler_if::value>::type = sprout::enabler + typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR int int_digit_at(IntType val, int digits) { diff --git a/sprout/detail/pow.hpp b/sprout/detail/pow.hpp index 988edb15..c9820885 100644 --- a/sprout/detail/pow.hpp +++ b/sprout/detail/pow.hpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include @@ -48,7 +48,7 @@ namespace sprout { } template< typename T, typename IntType, - typename sprout::enabler_if::value>::type = sprout::enabler + typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR T pow_n(T const& x, IntType n) { diff --git a/sprout/functional/bind/bind.hpp b/sprout/functional/bind/bind.hpp index 2421067a..2e99ba46 100644 --- a/sprout/functional/bind/bind.hpp +++ b/sprout/functional/bind/bind.hpp @@ -29,6 +29,7 @@ #include #include #include +#include namespace sprout { // 20.8.9 bind @@ -514,9 +515,9 @@ namespace sprout { binder(binder const&) = default; template< typename... Args, - typename Result = decltype( + typename Result = typename sprout::identity >(), sprout::detail::bound_indexes::make()) - ) + )>::type > Result operator()(Args&&... args) { return impl_type::template call( @@ -526,9 +527,9 @@ namespace sprout { } template< typename... Args, - typename Result = decltype( + typename Result = typename sprout::identity >(), sprout::detail::bound_indexes::make()) - ) + )>::type > SPROUT_CONSTEXPR Result operator()(Args&&... args) const { return impl_type::template call_c( @@ -538,9 +539,9 @@ namespace sprout { } template< typename... Args, - typename Result = decltype( + typename Result = typename sprout::identity >(), sprout::detail::bound_indexes::make()) - ) + )>::type > Result operator()(Args&&... args) volatile { return impl_type::template call_v( @@ -550,9 +551,9 @@ namespace sprout { } template< typename... Args, - typename Result = decltype( + typename Result = typename sprout::identity >(), sprout::detail::bound_indexes::make()) - ) + )>::type > SPROUT_CONSTEXPR Result operator()(Args&&... args) const volatile { return impl_type::template call_cv( @@ -581,9 +582,9 @@ namespace sprout { cbinder(cbinder const&) = default; template< typename... Args, - typename Result = decltype( + typename Result = typename sprout::identity >(), sprout::detail::bound_indexes::make()) - ) + )>::type > SPROUT_CONSTEXPR Result operator()(Args&&... args) const { return impl_type::template call_c( @@ -593,9 +594,9 @@ namespace sprout { } template< typename... Args, - typename Result = decltype( + typename Result = typename sprout::identity >(), sprout::detail::bound_indexes::make()) - ) + )>::type > SPROUT_CONSTEXPR Result operator()(Args&&... args) const volatile { return impl_type::template call_cv( diff --git a/sprout/generator/generator_access_traits.hpp b/sprout/generator/generator_access_traits.hpp index d5f423ee..aec278b0 100644 --- a/sprout/generator/generator_access_traits.hpp +++ b/sprout/generator/generator_access_traits.hpp @@ -23,13 +23,13 @@ namespace sprout { public: template< typename U = T, - typename = decltype(std::declval().generated_value()) + typename = typename sprout::identity().generated_value())>::type > static sprout::true_type test(int); static sprout::false_type test(...); }; #if defined(_MSC_VER) - template::test(0))> + template::test(0))>::type> struct has_mem_generated_value : public Base_ {}; @@ -98,13 +98,13 @@ namespace sprout { public: template< typename U = T, - typename = decltype(std::declval().next_generator()) + typename = typename sprout::identity().next_generator())>::type > static sprout::true_type test(int); static sprout::false_type test(...); }; #if defined(_MSC_VER) - template::test(0))> + template::test(0))>::type> struct has_mem_next_generator : public Base_ {}; diff --git a/sprout/math/factorial.hpp b/sprout/math/factorial.hpp index 9fe5f02c..f4fbffdb 100644 --- a/sprout/math/factorial.hpp +++ b/sprout/math/factorial.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -530,7 +530,7 @@ namespace sprout { struct factorials; template - struct factorials::value && sizeof(T) == 1>::type> { + struct factorials::value && sizeof(T) == 1>::type> { public: typedef T type; public: @@ -544,9 +544,9 @@ namespace sprout { }; template SPROUT_CONSTEXPR_OR_CONST typename sprout::math::detail::factorials< - T, typename std::enable_if::value && sizeof(T) == 1>::type + T, typename std::enable_if::value && sizeof(T) == 1>::type >::table_type sprout::math::detail::factorials< - T, typename std::enable_if::value && sizeof(T) == 1>::type + T, typename std::enable_if::value && sizeof(T) == 1>::type >::table SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(SPROUT_FACTORIAL_TABLE_DEF_INT_1); template @@ -570,7 +570,7 @@ namespace sprout { >::table SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(SPROUT_FACTORIAL_TABLE_DEF_UINT_1); template - struct factorials::value && sizeof(T) == 2>::type> { + struct factorials::value && sizeof(T) == 2>::type> { public: typedef T type; public: @@ -584,9 +584,9 @@ namespace sprout { }; template SPROUT_CONSTEXPR_OR_CONST typename sprout::math::detail::factorials< - T, typename std::enable_if::value && sizeof(T) == 2>::type + T, typename std::enable_if::value && sizeof(T) == 2>::type >::table_type sprout::math::detail::factorials< - T, typename std::enable_if::value && sizeof(T) == 2>::type + T, typename std::enable_if::value && sizeof(T) == 2>::type >::table SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(SPROUT_FACTORIAL_TABLE_DEF_INT_2); template @@ -610,7 +610,7 @@ namespace sprout { >::table SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(SPROUT_FACTORIAL_TABLE_DEF_UINT_2); template - struct factorials::value && sizeof(T) == 4>::type> { + struct factorials::value && sizeof(T) == 4>::type> { public: typedef T type; public: @@ -624,9 +624,9 @@ namespace sprout { }; template SPROUT_CONSTEXPR_OR_CONST typename sprout::math::detail::factorials< - T, typename std::enable_if::value && sizeof(T) == 4>::type + T, typename std::enable_if::value && sizeof(T) == 4>::type >::table_type sprout::math::detail::factorials< - T, typename std::enable_if::value && sizeof(T) == 4>::type + T, typename std::enable_if::value && sizeof(T) == 4>::type >::table SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(SPROUT_FACTORIAL_TABLE_DEF_INT_4); template @@ -650,7 +650,7 @@ namespace sprout { >::table SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(SPROUT_FACTORIAL_TABLE_DEF_UINT_4); template - struct factorials::value && sizeof(T) == 8>::type> { + struct factorials::value && sizeof(T) == 8>::type> { public: typedef T type; public: @@ -664,9 +664,9 @@ namespace sprout { }; template SPROUT_CONSTEXPR_OR_CONST typename sprout::math::detail::factorials< - T, typename std::enable_if::value && sizeof(T) == 8>::type + T, typename std::enable_if::value && sizeof(T) == 8>::type >::table_type sprout::math::detail::factorials< - T, typename std::enable_if::value && sizeof(T) == 8>::type + T, typename std::enable_if::value && sizeof(T) == 8>::type >::table SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(SPROUT_FACTORIAL_TABLE_DEF_INT_8); template diff --git a/sprout/random/type_traits.hpp b/sprout/random/type_traits.hpp index 34b73473..49f688f7 100644 --- a/sprout/random/type_traits.hpp +++ b/sprout/random/type_traits.hpp @@ -8,7 +8,9 @@ #ifndef SPROUT_RANDOM_TYPE_TRAITS_HPP #define SPROUT_RANDOM_TYPE_TRAITS_HPP +#include #include +#include #include namespace sprout { @@ -17,6 +19,45 @@ namespace sprout { // is_seed_seq // SPROUT_HAS_XXX_TYPE_DEF(is_seed_seq, result_type); + + // + // is_real_std_random_parameter + // is_int_std_random_parameter + // is_uint_std_random_parameter + // + template + struct is_real_std_random_parameter + : public sprout::integral_constant< + bool, + std::is_same::value + || std::is_same::value + || std::is_same::value + > + {}; + template + struct is_int_std_random_parameter + : public sprout::integral_constant< + bool, + std::is_same::value + || std::is_same::value + || std::is_same::value + || std::is_same::value + || std::is_same::value + || std::is_same::value + || std::is_same::value + || std::is_same::value + > + {}; + template + struct is_uint_std_random_parameter + : public sprout::integral_constant< + bool, + std::is_same::value + || std::is_same::value + || std::is_same::value + || std::is_same::value + > + {}; } // namespace random } // namespace sprout diff --git a/sprout/type_traits.hpp b/sprout/type_traits.hpp index e7978633..e472419b 100644 --- a/sprout/type_traits.hpp +++ b/sprout/type_traits.hpp @@ -11,7 +11,10 @@ #include #include #include -#include +#include +#include +#include +#include #include #include #include diff --git a/sprout/type_traits/is_const_unqualified.hpp b/sprout/type_traits/is_const_unqualified.hpp new file mode 100644 index 00000000..3d3a6a40 --- /dev/null +++ b/sprout/type_traits/is_const_unqualified.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2011-2014 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_TYPE_TRAITS_IS_CONST_UNQUALIFIED_HPP +#define SPROUT_TYPE_TRAITS_IS_CONST_UNQUALIFIED_HPP + +#include +#include +#include + +namespace sprout { + // + // is_const_unqualified + // + template + struct is_const_unqualified + : public sprout::integral_constant< + bool, + std::is_const::value + > + {}; +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_IS_CONST_UNQUALIFIED_HPP diff --git a/sprout/type_traits/is_cv_unqualified.hpp b/sprout/type_traits/is_cv_unqualified.hpp new file mode 100644 index 00000000..eee92d7c --- /dev/null +++ b/sprout/type_traits/is_cv_unqualified.hpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2011-2014 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_TYPE_TRAITS_IS_CV_UNQUALIFIED_HPP +#define SPROUT_TYPE_TRAITS_IS_CV_UNQUALIFIED_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // is_cv_unqualified + // + template + struct is_cv_unqualified + : public sprout::integral_constant< + bool, + sprout::is_const_unqualified::value && sprout::is_volatile_unqualified::value + > + {}; +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_IS_CV_UNQUALIFIED_HPP diff --git a/sprout/type_traits/is_int.hpp b/sprout/type_traits/is_sint.hpp similarity index 76% rename from sprout/type_traits/is_int.hpp rename to sprout/type_traits/is_sint.hpp index ced70563..24fa1b63 100644 --- a/sprout/type_traits/is_int.hpp +++ b/sprout/type_traits/is_sint.hpp @@ -5,8 +5,8 @@ Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ -#ifndef SPROUT_TYPE_TRAITS_IS_INT_HPP -#define SPROUT_TYPE_TRAITS_IS_INT_HPP +#ifndef SPROUT_TYPE_TRAITS_IS_SINT_HPP +#define SPROUT_TYPE_TRAITS_IS_SINT_HPP #include #include @@ -14,10 +14,10 @@ namespace sprout { // - // is_int + // is_sint // template - struct is_int + struct is_sint : public sprout::integral_constant< bool, std::is_integral::value && std::is_signed::value @@ -26,8 +26,8 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using is_int_t = typename sprout::is_int::type; + using is_sint_t = typename sprout::is_sint::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout -#endif // #ifndef SPROUT_TYPE_TRAITS_IS_INT_HPP +#endif // #ifndef SPROUT_TYPE_TRAITS_IS_SINT_HPP diff --git a/sprout/type_traits/is_volatile_unqualified.hpp b/sprout/type_traits/is_volatile_unqualified.hpp new file mode 100644 index 00000000..64f31fd1 --- /dev/null +++ b/sprout/type_traits/is_volatile_unqualified.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2011-2014 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_TYPE_TRAITS_IS_VOLATILE_UNQUALIFIED_HPP +#define SPROUT_TYPE_TRAITS_IS_VOLATILE_UNQUALIFIED_HPP + +#include +#include +#include + +namespace sprout { + // + // is_volatile_unqualified + // + template + struct is_volatile_unqualified + : public sprout::integral_constant< + bool, + std::is_volatile::value + > + {}; +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_IS_VOLATILE_UNQUALIFIED_HPP