diff --git a/sprout/type.hpp b/sprout/type.hpp index 1ea86eb1..d0437103 100644 --- a/sprout/type.hpp +++ b/sprout/type.hpp @@ -18,7 +18,9 @@ #include #include #include +#include #include +#include #include #include #include diff --git a/sprout/type/algorithm/transform.hpp b/sprout/type/algorithm/transform.hpp index 37d8c611..ce6399dd 100644 --- a/sprout/type/algorithm/transform.hpp +++ b/sprout/type/algorithm/transform.hpp @@ -14,20 +14,11 @@ #include #include #include +#include namespace sprout { namespace types { namespace detail { - template - struct transform_impl; - template - struct transform_impl > - : public sprout::types::apply< - sprout::types::rebind_types, - typename sprout::types::apply::type>::type... - > - {}; - template struct transform2_impl; template @@ -54,10 +45,7 @@ namespace sprout { {}; template struct transform - : public sprout::types::detail::transform_impl< - Tuple, UnaryOp, - typename sprout::tuple_indexes::type - > + : public sprout::types::apply, UnaryOp> {}; #if SPROUT_USE_TEMPLATE_ALIASES diff --git a/sprout/type/functional/arithmetic.hpp b/sprout/type/functional/arithmetic.hpp index 7fd14386..c7b1e95c 100644 --- a/sprout/type/functional/arithmetic.hpp +++ b/sprout/type/functional/arithmetic.hpp @@ -14,5 +14,7 @@ #include #include #include +#include +#include #endif // #ifndef SPROUT_TYPE_FUNCTIONAL_ARITHMETIC_HPP diff --git a/sprout/type/functional/detail/arithmetic_op.hpp b/sprout/type/functional/detail/arithmetic_op.hpp index 56990eed..1174438f 100644 --- a/sprout/type/functional/detail/arithmetic_op.hpp +++ b/sprout/type/functional/detail/arithmetic_op.hpp @@ -47,4 +47,38 @@ namespace sprout { \ # define SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_BINARY_OP_VT_DECL(NAME) #endif // #if SPROUT_USE_VARIABLE_TEMPLATES +#define SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_UNARY_OP_DECL(NAME, OP) \ +namespace sprout { \ + namespace types { \ + template \ + struct NAME \ + : public sprout::integral_constant \ + {}; \ + template \ + struct NAME \ + : public sprout::integral_constant< \ + typename sprout::arithmetic_promote::type, \ + (OP T::value) \ + > \ + {}; \ + template \ + struct SPROUT_PP_CAT(NAME, _mf) { \ + public: \ + template \ + struct apply \ + : public sprout::types::NAME \ + {}; \ + }; \ + typedef sprout::types::SPROUT_PP_CAT(NAME, _mf)<> SPROUT_PP_CAT(NAME, _); \ + SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_UNARY_OP_VT_DECL(NAME) \ + } \ +} +#if SPROUT_USE_VARIABLE_TEMPLATES +# define SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_UNARY_OP_VT_DECL(NAME) \ + template \ + SPROUT_STATIC_CONSTEXPR typename sprout::types::NAME::value_type SPROUT_PP_CAT(NAME, _v) = sprout::types::NAME::value; +#else // #if SPROUT_USE_VARIABLE_TEMPLATES +# define SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_UNARY_OP_VT_DECL(NAME) +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES + #endif // #ifndef SPROUT_TYPE_FUNCTIONAL_DETAIL_ARITHMETIC_OP_HPP diff --git a/sprout/type/functional/divides.hpp b/sprout/type/functional/divides.hpp index a3ac5d58..ad3a78da 100644 --- a/sprout/type/functional/divides.hpp +++ b/sprout/type/functional/divides.hpp @@ -11,6 +11,11 @@ #include #include +// +// divides +// divides_mf +// divides_ +// SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_BINARY_OP_DECL(divides, /) #endif // #ifndef SPROUT_TYPE_FUNCTIONAL_DIVIDES_HPP diff --git a/sprout/type/functional/equal_to.hpp b/sprout/type/functional/equal_to.hpp index 586b5608..ea36a343 100644 --- a/sprout/type/functional/equal_to.hpp +++ b/sprout/type/functional/equal_to.hpp @@ -11,6 +11,10 @@ #include #include +// +// equal_to +// equal_to_ +// SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(equal_to, ==) #endif // #ifndef SPROUT_TYPE_FUNCTIONAL_EQUAL_TO_HPP diff --git a/sprout/type/functional/greater.hpp b/sprout/type/functional/greater.hpp index 74e9819e..4f55166c 100644 --- a/sprout/type/functional/greater.hpp +++ b/sprout/type/functional/greater.hpp @@ -11,6 +11,10 @@ #include #include +// +// greater +// greater_ +// SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(greater, >) #endif // #ifndef SPROUT_TYPE_FUNCTIONAL_GREATER_HPP diff --git a/sprout/type/functional/greater_equal.hpp b/sprout/type/functional/greater_equal.hpp index d3ac2751..2f355375 100644 --- a/sprout/type/functional/greater_equal.hpp +++ b/sprout/type/functional/greater_equal.hpp @@ -11,6 +11,10 @@ #include #include +// +// greater_equal +// greater_equal_ +// SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(greater_equal, >=) #endif // #ifndef SPROUT_TYPE_FUNCTIONAL_GREATER_EQUAL_HPP diff --git a/sprout/type/functional/less.hpp b/sprout/type/functional/less.hpp index 22e6861d..c48843fb 100644 --- a/sprout/type/functional/less.hpp +++ b/sprout/type/functional/less.hpp @@ -11,6 +11,10 @@ #include #include +// +// less +// less_ +// SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(less, <) #endif // #ifndef SPROUT_TYPE_FUNCTIONAL_LESS_HPP diff --git a/sprout/type/functional/less_equal.hpp b/sprout/type/functional/less_equal.hpp index 97452149..e438ec8e 100644 --- a/sprout/type/functional/less_equal.hpp +++ b/sprout/type/functional/less_equal.hpp @@ -11,6 +11,10 @@ #include #include +// +// less_equal +// less_equal_ +// SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(less_equal, <=) #endif // #ifndef SPROUT_TYPE_FUNCTIONAL_LESS_EQUAL_HPP diff --git a/sprout/type/functional/minus.hpp b/sprout/type/functional/minus.hpp index 18cfd83f..996f125e 100644 --- a/sprout/type/functional/minus.hpp +++ b/sprout/type/functional/minus.hpp @@ -11,6 +11,11 @@ #include #include +// +// minus +// minus_mf +// minus_ +// SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_BINARY_OP_DECL(minus, -) #endif // #ifndef SPROUT_TYPE_FUNCTIONAL_MINUS_HPP diff --git a/sprout/type/functional/modulus.hpp b/sprout/type/functional/modulus.hpp index 87775ea7..89c10c40 100644 --- a/sprout/type/functional/modulus.hpp +++ b/sprout/type/functional/modulus.hpp @@ -11,6 +11,11 @@ #include #include +// +// modulus +// modulus_mf +// modulus_ +// SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_BINARY_OP_DECL(modulus, %) #endif // #ifndef SPROUT_TYPE_FUNCTIONAL_MODULUS_HPP diff --git a/sprout/type/functional/multiplies.hpp b/sprout/type/functional/multiplies.hpp index e66621e8..3d9891aa 100644 --- a/sprout/type/functional/multiplies.hpp +++ b/sprout/type/functional/multiplies.hpp @@ -11,6 +11,11 @@ #include #include +// +// multiplies +// multiplies_mf +// multiplies_ +// SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_BINARY_OP_DECL(multiplies, *) #endif // #ifndef SPROUT_TYPE_FUNCTIONAL_MULTIPLIES_HPP diff --git a/sprout/type/functional/negate.hpp b/sprout/type/functional/negate.hpp new file mode 100644 index 00000000..ee11e245 --- /dev/null +++ b/sprout/type/functional/negate.hpp @@ -0,0 +1,21 @@ +/*============================================================================= + 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_FUNCTIONAL_NEGATE_HPP +#define SPROUT_TYPE_FUNCTIONAL_NEGATE_HPP + +#include +#include + +// +// negate +// negate_mf +// negate_ +// +SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_UNARY_OP_DECL(negate, -) + +#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_NEGATE_HPP diff --git a/sprout/type/functional/not_equal_to.hpp b/sprout/type/functional/not_equal_to.hpp index 9ea8b135..61e45dae 100644 --- a/sprout/type/functional/not_equal_to.hpp +++ b/sprout/type/functional/not_equal_to.hpp @@ -11,6 +11,10 @@ #include #include +// +// not_equal_to +// not_equal_to_ +// SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(not_equal_to, !=) #endif // #ifndef SPROUT_TYPE_FUNCTIONAL_NOT_EQUAL_TO_HPP diff --git a/sprout/type/functional/posite.hpp b/sprout/type/functional/posite.hpp new file mode 100644 index 00000000..040850e8 --- /dev/null +++ b/sprout/type/functional/posite.hpp @@ -0,0 +1,21 @@ +/*============================================================================= + 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_FUNCTIONAL_POSITE_HPP +#define SPROUT_TYPE_FUNCTIONAL_POSITE_HPP + +#include +#include + +// +// posite +// posite_mf +// posite_ +// +SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_UNARY_OP_DECL(posite, +) + +#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_POSITE_HPP diff --git a/sprout/type/map_types.hpp b/sprout/type/map_types.hpp new file mode 100644 index 00000000..240e7e2f --- /dev/null +++ b/sprout/type/map_types.hpp @@ -0,0 +1,125 @@ +/*============================================================================= + 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_MAP_TYPES_HPP +#define SPROUT_TYPE_MAP_TYPES_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace types { + namespace detail { + template + struct map_types_default { + private: + template + struct apply_impl; + template + struct apply_impl > + : public sprout::types::apply< + sprout::types::rebind_types, + typename sprout::types::apply::type>::type... + > + {}; + public: + template + struct apply + : public apply_impl::type> + {}; + }; + template class TupleClass, typename... Ts> + struct map_types_default > { + public: + template + struct apply + : public sprout::identity::type...> > + {}; + }; + template class IntegerSequenceClass, typename T, T... Vs> + struct map_types_default > { + public: + template + struct apply + : public sprout::identity >::type::value...> > + {}; + }; + +#define SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(TYPE) \ + template class IndexTupleClass, TYPE... Vs> \ + struct map_types_default > { \ + public: \ + template \ + struct apply \ + : public sprout::identity >::type::value...> > \ + {}; \ + } + + SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(bool); + SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(char); + SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(signed char); + SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(unsigned char); + SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(char16_t); + SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(char32_t); + SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(wchar_t); + SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(short); + SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(unsigned short); + SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(int); + SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(unsigned int); + SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(long); + SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(unsigned long); + SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(long long); + SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(unsigned long long); + +#undef SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL + } // namespace detail + + // + // map_types + // + template + struct map_types + : public sprout::types::detail::map_types_default + {}; + + template + struct map_types { + public: + template + struct apply + : public sprout::identity, Op>::type const> + {}; + }; + + template + struct map_types { + public: + template + struct apply + : public sprout::identity, Op>::type volatile> + {}; + }; + + template + struct map_types { + public: + template + struct apply + : public sprout::identity, Op>::type const volatile> + {}; + }; + } // namespace types + + using sprout::types::map_types; +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_MAP_TYPES_HPP diff --git a/sprout/type/operation.hpp b/sprout/type/operation.hpp index f4823f33..b748f9a4 100644 --- a/sprout/type/operation.hpp +++ b/sprout/type/operation.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #endif // #ifndef SPROUT_TYPE_OPERATION_HPP diff --git a/sprout/type/operation/map.hpp b/sprout/type/operation/map.hpp new file mode 100644 index 00000000..24a6500f --- /dev/null +++ b/sprout/type/operation/map.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + 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_OPERATION_MAP_HPP +#define SPROUT_TYPE_OPERATION_MAP_HPP + +#include +#include +#include + +namespace sprout { + namespace types { + // + // map + // + template + struct map + : public sprout::types::apply, Op> + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using map_t = typename sprout::types::map::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_OPERATION_MAP_HPP diff --git a/sprout/type/operation/pop_front.hpp b/sprout/type/operation/pop_front.hpp index ccfd418f..f0961db4 100644 --- a/sprout/type/operation/pop_front.hpp +++ b/sprout/type/operation/pop_front.hpp @@ -9,10 +9,8 @@ #define SPROUT_TYPE_OPERATION_POP_FRONT_HPP #include -#include #include -#include -#include +#include namespace sprout { namespace types { @@ -20,22 +18,9 @@ namespace sprout { // pop_front // template - struct pop_front { - private: - template - struct apply_impl; - template - struct apply_impl > - : public sprout::types::apply< - sprout::types::rebind_types, - typename sprout::types::tuple_element::type... - > - {}; - public: - typedef typename apply_impl< - typename sprout::index_range<1, sprout::types::tuple_size::value>::type - >::type type; - }; + struct pop_front + : public sprout::types::apply > + {}; #if SPROUT_USE_TEMPLATE_ALIASES template diff --git a/sprout/type/pop_front_types.hpp b/sprout/type/pop_front_types.hpp new file mode 100644 index 00000000..653403fd --- /dev/null +++ b/sprout/type/pop_front_types.hpp @@ -0,0 +1,123 @@ +/*============================================================================= + 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_POP_FRONT_TYPES_HPP +#define SPROUT_TYPE_POP_FRONT_TYPES_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace types { + namespace detail { + template + struct pop_front_types_default { + template + struct apply_impl; + template + struct apply_impl > + : public sprout::types::apply< + sprout::types::rebind_types, + typename sprout::types::tuple_element::type... + > + {}; + public: + template + struct apply + : public apply_impl::value>::type> + {}; + }; + template class TupleClass, typename Head, typename... Tail> + struct pop_front_types_default > { + public: + template + struct apply + : public sprout::identity > + {}; + }; + template class IntegerSequenceClass, typename T, T Head, T... Tail> + struct pop_front_types_default > { + public: + template + struct apply + : public sprout::identity > + {}; + }; + +#define SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(TYPE) \ + template class IndexTupleClass, TYPE Head, TYPE... Tail> \ + struct pop_front_types_default > { \ + public: \ + template \ + struct apply \ + : public sprout::identity > \ + {}; \ + } + + SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(bool); + SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(char); + SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(signed char); + SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(unsigned char); + SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(char16_t); + SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(char32_t); + SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(wchar_t); + SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(short); + SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(unsigned short); + SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(int); + SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(unsigned int); + SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(long); + SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(unsigned long); + SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(long long); + SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(unsigned long long); + +#undef SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL + } // namespace detail + + // + // pop_front_types + // + template + struct pop_front_types + : public sprout::types::detail::pop_front_types_default + {}; + + template + struct pop_front_types { + public: + template + struct apply + : public sprout::identity, Types...>::type const> + {}; + }; + + template + struct pop_front_types { + public: + template + struct apply + : public sprout::identity, Types...>::type volatile> + {}; + }; + + template + struct pop_front_types { + public: + template + struct apply + : public sprout::identity, Types...>::type const volatile> + {}; + }; + } // namespace types + + using sprout::types::pop_front_types; +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_POP_FRONT_TYPES_HPP diff --git a/sprout/type/rebind_types.hpp b/sprout/type/rebind_types.hpp index 0d6ad463..c5fd0362 100644 --- a/sprout/type/rebind_types.hpp +++ b/sprout/type/rebind_types.hpp @@ -10,7 +10,6 @@ #include #include -#include #include namespace sprout {