mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2024-11-12 21:09:01 +00:00
fix type operation implementation
This commit is contained in:
parent
8418b81099
commit
ec03e6f9c0
22 changed files with 411 additions and 34 deletions
|
@ -18,7 +18,9 @@
|
||||||
#include <sprout/type/string.hpp>
|
#include <sprout/type/string.hpp>
|
||||||
#include <sprout/type/uniform_types.hpp>
|
#include <sprout/type/uniform_types.hpp>
|
||||||
#include <sprout/type/rebind_types.hpp>
|
#include <sprout/type/rebind_types.hpp>
|
||||||
|
#include <sprout/type/map_types.hpp>
|
||||||
#include <sprout/type/joint_types.hpp>
|
#include <sprout/type/joint_types.hpp>
|
||||||
|
#include <sprout/type/pop_front_types.hpp>
|
||||||
#include <sprout/type/functional.hpp>
|
#include <sprout/type/functional.hpp>
|
||||||
#include <sprout/type/algorithm.hpp>
|
#include <sprout/type/algorithm.hpp>
|
||||||
#include <sprout/type/seq/algorithm.hpp>
|
#include <sprout/type/seq/algorithm.hpp>
|
||||||
|
|
|
@ -14,20 +14,11 @@
|
||||||
#include <sprout/type/apply.hpp>
|
#include <sprout/type/apply.hpp>
|
||||||
#include <sprout/type/tuple.hpp>
|
#include <sprout/type/tuple.hpp>
|
||||||
#include <sprout/type/rebind_types.hpp>
|
#include <sprout/type/rebind_types.hpp>
|
||||||
|
#include <sprout/type/map_types.hpp>
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
namespace types {
|
namespace types {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename Tuple, typename UnaryOp, typename IndexTuple>
|
|
||||||
struct transform_impl;
|
|
||||||
template<typename Tuple, typename UnaryOp, sprout::index_t... Indexes>
|
|
||||||
struct transform_impl<Tuple, UnaryOp, sprout::index_tuple<Indexes...> >
|
|
||||||
: public sprout::types::apply<
|
|
||||||
sprout::types::rebind_types<Tuple>,
|
|
||||||
typename sprout::types::apply<UnaryOp, typename sprout::types::tuple_element<Indexes, Tuple>::type>::type...
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
|
|
||||||
template<typename Tuple1, typename Tuple2, typename BinaryOp, typename IndexTuple>
|
template<typename Tuple1, typename Tuple2, typename BinaryOp, typename IndexTuple>
|
||||||
struct transform2_impl;
|
struct transform2_impl;
|
||||||
template<typename Tuple1, typename Tuple2, typename BinaryOp, sprout::index_t... Indexes>
|
template<typename Tuple1, typename Tuple2, typename BinaryOp, sprout::index_t... Indexes>
|
||||||
|
@ -54,10 +45,7 @@ namespace sprout {
|
||||||
{};
|
{};
|
||||||
template<typename Tuple, typename UnaryOp>
|
template<typename Tuple, typename UnaryOp>
|
||||||
struct transform<Tuple, UnaryOp, void>
|
struct transform<Tuple, UnaryOp, void>
|
||||||
: public sprout::types::detail::transform_impl<
|
: public sprout::types::apply<sprout::types::map_types<Tuple>, UnaryOp>
|
||||||
Tuple, UnaryOp,
|
|
||||||
typename sprout::tuple_indexes<Tuple>::type
|
|
||||||
>
|
|
||||||
{};
|
{};
|
||||||
|
|
||||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||||
|
|
|
@ -14,5 +14,7 @@
|
||||||
#include <sprout/type/functional/multiplies.hpp>
|
#include <sprout/type/functional/multiplies.hpp>
|
||||||
#include <sprout/type/functional/divides.hpp>
|
#include <sprout/type/functional/divides.hpp>
|
||||||
#include <sprout/type/functional/modulus.hpp>
|
#include <sprout/type/functional/modulus.hpp>
|
||||||
|
#include <sprout/type/functional/posite.hpp>
|
||||||
|
#include <sprout/type/functional/negate.hpp>
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_ARITHMETIC_HPP
|
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_ARITHMETIC_HPP
|
||||||
|
|
|
@ -47,4 +47,38 @@ namespace sprout { \
|
||||||
# define SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_BINARY_OP_VT_DECL(NAME)
|
# define SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_BINARY_OP_VT_DECL(NAME)
|
||||||
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
|
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
|
||||||
|
|
||||||
|
#define SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_UNARY_OP_DECL(NAME, OP) \
|
||||||
|
namespace sprout { \
|
||||||
|
namespace types { \
|
||||||
|
template<typename T, typename Result = void> \
|
||||||
|
struct NAME \
|
||||||
|
: public sprout::integral_constant<Result, (OP T::value)> \
|
||||||
|
{}; \
|
||||||
|
template<typename T> \
|
||||||
|
struct NAME<T, void> \
|
||||||
|
: public sprout::integral_constant< \
|
||||||
|
typename sprout::arithmetic_promote<typename T::value_type>::type, \
|
||||||
|
(OP T::value) \
|
||||||
|
> \
|
||||||
|
{}; \
|
||||||
|
template<typename Result = void> \
|
||||||
|
struct SPROUT_PP_CAT(NAME, _mf) { \
|
||||||
|
public: \
|
||||||
|
template<typename T> \
|
||||||
|
struct apply \
|
||||||
|
: public sprout::types::NAME<T, Result> \
|
||||||
|
{}; \
|
||||||
|
}; \
|
||||||
|
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<typename T, typename Result = void> \
|
||||||
|
SPROUT_STATIC_CONSTEXPR typename sprout::types::NAME<T, Result>::value_type SPROUT_PP_CAT(NAME, _v) = sprout::types::NAME<T, Result>::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
|
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_DETAIL_ARITHMETIC_OP_HPP
|
||||||
|
|
|
@ -11,6 +11,11 @@
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/type/functional/detail/arithmetic_op.hpp>
|
#include <sprout/type/functional/detail/arithmetic_op.hpp>
|
||||||
|
|
||||||
|
//
|
||||||
|
// divides
|
||||||
|
// divides_mf
|
||||||
|
// divides_
|
||||||
|
//
|
||||||
SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_BINARY_OP_DECL(divides, /)
|
SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_BINARY_OP_DECL(divides, /)
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_DIVIDES_HPP
|
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_DIVIDES_HPP
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/type/functional/detail/comparison_op.hpp>
|
#include <sprout/type/functional/detail/comparison_op.hpp>
|
||||||
|
|
||||||
|
//
|
||||||
|
// equal_to
|
||||||
|
// equal_to_
|
||||||
|
//
|
||||||
SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(equal_to, ==)
|
SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(equal_to, ==)
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_EQUAL_TO_HPP
|
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_EQUAL_TO_HPP
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/type/functional/detail/comparison_op.hpp>
|
#include <sprout/type/functional/detail/comparison_op.hpp>
|
||||||
|
|
||||||
|
//
|
||||||
|
// greater
|
||||||
|
// greater_
|
||||||
|
//
|
||||||
SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(greater, >)
|
SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(greater, >)
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_GREATER_HPP
|
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_GREATER_HPP
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/type/functional/detail/comparison_op.hpp>
|
#include <sprout/type/functional/detail/comparison_op.hpp>
|
||||||
|
|
||||||
|
//
|
||||||
|
// greater_equal
|
||||||
|
// greater_equal_
|
||||||
|
//
|
||||||
SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(greater_equal, >=)
|
SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(greater_equal, >=)
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_GREATER_EQUAL_HPP
|
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_GREATER_EQUAL_HPP
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/type/functional/detail/comparison_op.hpp>
|
#include <sprout/type/functional/detail/comparison_op.hpp>
|
||||||
|
|
||||||
|
//
|
||||||
|
// less
|
||||||
|
// less_
|
||||||
|
//
|
||||||
SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(less, <)
|
SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(less, <)
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_LESS_HPP
|
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_LESS_HPP
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/type/functional/detail/comparison_op.hpp>
|
#include <sprout/type/functional/detail/comparison_op.hpp>
|
||||||
|
|
||||||
|
//
|
||||||
|
// less_equal
|
||||||
|
// less_equal_
|
||||||
|
//
|
||||||
SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(less_equal, <=)
|
SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(less_equal, <=)
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_LESS_EQUAL_HPP
|
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_LESS_EQUAL_HPP
|
||||||
|
|
|
@ -11,6 +11,11 @@
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/type/functional/detail/arithmetic_op.hpp>
|
#include <sprout/type/functional/detail/arithmetic_op.hpp>
|
||||||
|
|
||||||
|
//
|
||||||
|
// minus
|
||||||
|
// minus_mf
|
||||||
|
// minus_
|
||||||
|
//
|
||||||
SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_BINARY_OP_DECL(minus, -)
|
SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_BINARY_OP_DECL(minus, -)
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_MINUS_HPP
|
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_MINUS_HPP
|
||||||
|
|
|
@ -11,6 +11,11 @@
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/type/functional/detail/arithmetic_op.hpp>
|
#include <sprout/type/functional/detail/arithmetic_op.hpp>
|
||||||
|
|
||||||
|
//
|
||||||
|
// modulus
|
||||||
|
// modulus_mf
|
||||||
|
// modulus_
|
||||||
|
//
|
||||||
SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_BINARY_OP_DECL(modulus, %)
|
SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_BINARY_OP_DECL(modulus, %)
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_MODULUS_HPP
|
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_MODULUS_HPP
|
||||||
|
|
|
@ -11,6 +11,11 @@
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/type/functional/detail/arithmetic_op.hpp>
|
#include <sprout/type/functional/detail/arithmetic_op.hpp>
|
||||||
|
|
||||||
|
//
|
||||||
|
// multiplies
|
||||||
|
// multiplies_mf
|
||||||
|
// multiplies_
|
||||||
|
//
|
||||||
SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_BINARY_OP_DECL(multiplies, *)
|
SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_BINARY_OP_DECL(multiplies, *)
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_MULTIPLIES_HPP
|
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_MULTIPLIES_HPP
|
||||||
|
|
21
sprout/type/functional/negate.hpp
Normal file
21
sprout/type/functional/negate.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||||
|
#include <sprout/type/functional/detail/arithmetic_op.hpp>
|
||||||
|
|
||||||
|
//
|
||||||
|
// negate
|
||||||
|
// negate_mf
|
||||||
|
// negate_
|
||||||
|
//
|
||||||
|
SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_UNARY_OP_DECL(negate, -)
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_NEGATE_HPP
|
|
@ -11,6 +11,10 @@
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/type/functional/detail/comparison_op.hpp>
|
#include <sprout/type/functional/detail/comparison_op.hpp>
|
||||||
|
|
||||||
|
//
|
||||||
|
// not_equal_to
|
||||||
|
// not_equal_to_
|
||||||
|
//
|
||||||
SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(not_equal_to, !=)
|
SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_DECL(not_equal_to, !=)
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_NOT_EQUAL_TO_HPP
|
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_NOT_EQUAL_TO_HPP
|
||||||
|
|
21
sprout/type/functional/posite.hpp
Normal file
21
sprout/type/functional/posite.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||||
|
#include <sprout/type/functional/detail/arithmetic_op.hpp>
|
||||||
|
|
||||||
|
//
|
||||||
|
// posite
|
||||||
|
// posite_mf
|
||||||
|
// posite_
|
||||||
|
//
|
||||||
|
SPROUT_TYPES_DETAIL_FUNCTIONAL_ARITHMETIC_UNARY_OP_DECL(posite, +)
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_POSITE_HPP
|
125
sprout/type/map_types.hpp
Normal file
125
sprout/type/map_types.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||||
|
#include <sprout/type_traits/integral_constant.hpp>
|
||||||
|
#include <sprout/type_traits/identity.hpp>
|
||||||
|
#include <sprout/index_tuple/index_tuple.hpp>
|
||||||
|
#include <sprout/tuple/indexes.hpp>
|
||||||
|
#include <sprout/type/apply.hpp>
|
||||||
|
#include <sprout/type/rebind_types.hpp>
|
||||||
|
|
||||||
|
namespace sprout {
|
||||||
|
namespace types {
|
||||||
|
namespace detail {
|
||||||
|
template<typename Tuple>
|
||||||
|
struct map_types_default {
|
||||||
|
private:
|
||||||
|
template<typename Op, typename IndexTuple>
|
||||||
|
struct apply_impl;
|
||||||
|
template<typename Op, sprout::index_t... Indexes>
|
||||||
|
struct apply_impl<Op, sprout::index_tuple<Indexes...> >
|
||||||
|
: public sprout::types::apply<
|
||||||
|
sprout::types::rebind_types<Tuple>,
|
||||||
|
typename sprout::types::apply<Op, typename sprout::types::tuple_element<Indexes, Tuple>::type>::type...
|
||||||
|
>
|
||||||
|
{};
|
||||||
|
public:
|
||||||
|
template<typename Op>
|
||||||
|
struct apply
|
||||||
|
: public apply_impl<Op, typename sprout::tuple_indexes<Tuple>::type>
|
||||||
|
{};
|
||||||
|
};
|
||||||
|
template<template<typename...> class TupleClass, typename... Ts>
|
||||||
|
struct map_types_default<TupleClass<Ts...> > {
|
||||||
|
public:
|
||||||
|
template<typename Op>
|
||||||
|
struct apply
|
||||||
|
: public sprout::identity<TupleClass<typename sprout::types::apply<Op, Ts>::type...> >
|
||||||
|
{};
|
||||||
|
};
|
||||||
|
template<template<typename VT, VT...> class IntegerSequenceClass, typename T, T... Vs>
|
||||||
|
struct map_types_default<IntegerSequenceClass<T, Vs...> > {
|
||||||
|
public:
|
||||||
|
template<typename Op>
|
||||||
|
struct apply
|
||||||
|
: public sprout::identity<IntegerSequenceClass<T, sprout::types::apply<Op, sprout::integral_constant<T, Vs> >::type::value...> >
|
||||||
|
{};
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SPROUT_TYPES_DETAIL_MAP_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(TYPE) \
|
||||||
|
template<template<TYPE...> class IndexTupleClass, TYPE... Vs> \
|
||||||
|
struct map_types_default<IndexTupleClass<Vs...> > { \
|
||||||
|
public: \
|
||||||
|
template<typename Op> \
|
||||||
|
struct apply \
|
||||||
|
: public sprout::identity<IndexTupleClass<sprout::types::apply<Op, sprout::integral_constant<TYPE, Vs> >::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<typename Tuple>
|
||||||
|
struct map_types
|
||||||
|
: public sprout::types::detail::map_types_default<Tuple>
|
||||||
|
{};
|
||||||
|
|
||||||
|
template<typename Tuple>
|
||||||
|
struct map_types<Tuple const> {
|
||||||
|
public:
|
||||||
|
template<typename Op>
|
||||||
|
struct apply
|
||||||
|
: public sprout::identity<typename sprout::types::apply<sprout::types::map_types<Tuple>, Op>::type const>
|
||||||
|
{};
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Tuple>
|
||||||
|
struct map_types<Tuple volatile> {
|
||||||
|
public:
|
||||||
|
template<typename Op>
|
||||||
|
struct apply
|
||||||
|
: public sprout::identity<typename sprout::types::apply<sprout::types::map_types<Tuple>, Op>::type volatile>
|
||||||
|
{};
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Tuple>
|
||||||
|
struct map_types<Tuple const volatile> {
|
||||||
|
public:
|
||||||
|
template<typename Op>
|
||||||
|
struct apply
|
||||||
|
: public sprout::identity<typename sprout::types::apply<sprout::types::map_types<Tuple>, Op>::type const volatile>
|
||||||
|
{};
|
||||||
|
};
|
||||||
|
} // namespace types
|
||||||
|
|
||||||
|
using sprout::types::map_types;
|
||||||
|
} // namespace sprout
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_TYPE_MAP_TYPES_HPP
|
|
@ -22,6 +22,7 @@
|
||||||
#include <sprout/type/operation/pop_front.hpp>
|
#include <sprout/type/operation/pop_front.hpp>
|
||||||
#include <sprout/type/operation/tuple_cat.hpp>
|
#include <sprout/type/operation/tuple_cat.hpp>
|
||||||
#include <sprout/type/operation/rebind.hpp>
|
#include <sprout/type/operation/rebind.hpp>
|
||||||
|
#include <sprout/type/operation/map.hpp>
|
||||||
#include <sprout/type/operation/assign.hpp>
|
#include <sprout/type/operation/assign.hpp>
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_TYPE_OPERATION_HPP
|
#endif // #ifndef SPROUT_TYPE_OPERATION_HPP
|
||||||
|
|
32
sprout/type/operation/map.hpp
Normal file
32
sprout/type/operation/map.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||||
|
#include <sprout/type/apply.hpp>
|
||||||
|
#include <sprout/type/map_types.hpp>
|
||||||
|
|
||||||
|
namespace sprout {
|
||||||
|
namespace types {
|
||||||
|
//
|
||||||
|
// map
|
||||||
|
//
|
||||||
|
template<typename Tuple, typename Op>
|
||||||
|
struct map
|
||||||
|
: public sprout::types::apply<sprout::types::map_types<Tuple>, Op>
|
||||||
|
{};
|
||||||
|
|
||||||
|
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||||
|
template<typename Tuple, typename Op>
|
||||||
|
using map_t = typename sprout::types::map<Tuple, Op>::type;
|
||||||
|
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||||
|
} // namespace types
|
||||||
|
} // namespace sprout
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_TYPE_OPERATION_MAP_HPP
|
|
@ -9,10 +9,8 @@
|
||||||
#define SPROUT_TYPE_OPERATION_POP_FRONT_HPP
|
#define SPROUT_TYPE_OPERATION_POP_FRONT_HPP
|
||||||
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/index_tuple/metafunction.hpp>
|
|
||||||
#include <sprout/type/apply.hpp>
|
#include <sprout/type/apply.hpp>
|
||||||
#include <sprout/type/tuple.hpp>
|
#include <sprout/type/pop_front_types.hpp>
|
||||||
#include <sprout/type/rebind_types.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
namespace types {
|
namespace types {
|
||||||
|
@ -20,22 +18,9 @@ namespace sprout {
|
||||||
// pop_front
|
// pop_front
|
||||||
//
|
//
|
||||||
template<typename Tuple>
|
template<typename Tuple>
|
||||||
struct pop_front {
|
struct pop_front
|
||||||
private:
|
: public sprout::types::apply<sprout::types::pop_front_types<Tuple> >
|
||||||
template<typename IndexTuple>
|
{};
|
||||||
struct apply_impl;
|
|
||||||
template<sprout::index_t... Indexes>
|
|
||||||
struct apply_impl<sprout::index_tuple<Indexes...> >
|
|
||||||
: public sprout::types::apply<
|
|
||||||
sprout::types::rebind_types<Tuple>,
|
|
||||||
typename sprout::types::tuple_element<Indexes, Tuple>::type...
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
public:
|
|
||||||
typedef typename apply_impl<
|
|
||||||
typename sprout::index_range<1, sprout::types::tuple_size<Tuple>::value>::type
|
|
||||||
>::type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||||
template<typename Tuple>
|
template<typename Tuple>
|
||||||
|
|
123
sprout/type/pop_front_types.hpp
Normal file
123
sprout/type/pop_front_types.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||||
|
#include <sprout/index_tuple/metafunction.hpp>
|
||||||
|
#include <sprout/type_traits/identity.hpp>
|
||||||
|
#include <sprout/type/apply.hpp>
|
||||||
|
#include <sprout/type/tuple.hpp>
|
||||||
|
#include <sprout/type/rebind_types.hpp>
|
||||||
|
|
||||||
|
namespace sprout {
|
||||||
|
namespace types {
|
||||||
|
namespace detail {
|
||||||
|
template<typename Tuple>
|
||||||
|
struct pop_front_types_default {
|
||||||
|
template<typename IndexTuple>
|
||||||
|
struct apply_impl;
|
||||||
|
template<sprout::index_t... Indexes>
|
||||||
|
struct apply_impl<sprout::index_tuple<Indexes...> >
|
||||||
|
: public sprout::types::apply<
|
||||||
|
sprout::types::rebind_types<Tuple>,
|
||||||
|
typename sprout::types::tuple_element<Indexes, Tuple>::type...
|
||||||
|
>
|
||||||
|
{};
|
||||||
|
public:
|
||||||
|
template<typename = void>
|
||||||
|
struct apply
|
||||||
|
: public apply_impl<typename sprout::index_range<1, sprout::types::tuple_size<Tuple>::value>::type>
|
||||||
|
{};
|
||||||
|
};
|
||||||
|
template<template<typename...> class TupleClass, typename Head, typename... Tail>
|
||||||
|
struct pop_front_types_default<TupleClass<Head, Tail...> > {
|
||||||
|
public:
|
||||||
|
template<typename = void>
|
||||||
|
struct apply
|
||||||
|
: public sprout::identity<TupleClass<Tail...> >
|
||||||
|
{};
|
||||||
|
};
|
||||||
|
template<template<typename VT, VT...> class IntegerSequenceClass, typename T, T Head, T... Tail>
|
||||||
|
struct pop_front_types_default<IntegerSequenceClass<T, Head, Tail...> > {
|
||||||
|
public:
|
||||||
|
template<typename = void>
|
||||||
|
struct apply
|
||||||
|
: public sprout::identity<IntegerSequenceClass<T, Tail...> >
|
||||||
|
{};
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SPROUT_TYPES_DETAIL_POP_FRONT_TYPES_DEFAULT_INTEGER_SEQUENCE_LIKE_DECL(TYPE) \
|
||||||
|
template<template<TYPE...> class IndexTupleClass, TYPE Head, TYPE... Tail> \
|
||||||
|
struct pop_front_types_default<IndexTupleClass<Head, Tail...> > { \
|
||||||
|
public: \
|
||||||
|
template<typename = void> \
|
||||||
|
struct apply \
|
||||||
|
: public sprout::identity<IndexTupleClass<Tail...> > \
|
||||||
|
{}; \
|
||||||
|
}
|
||||||
|
|
||||||
|
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<typename Tuple>
|
||||||
|
struct pop_front_types
|
||||||
|
: public sprout::types::detail::pop_front_types_default<Tuple>
|
||||||
|
{};
|
||||||
|
|
||||||
|
template<typename Tuple>
|
||||||
|
struct pop_front_types<Tuple const> {
|
||||||
|
public:
|
||||||
|
template<typename... Types>
|
||||||
|
struct apply
|
||||||
|
: public sprout::identity<typename sprout::types::apply<sprout::types::pop_front_types<Tuple>, Types...>::type const>
|
||||||
|
{};
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Tuple>
|
||||||
|
struct pop_front_types<Tuple volatile> {
|
||||||
|
public:
|
||||||
|
template<typename... Types>
|
||||||
|
struct apply
|
||||||
|
: public sprout::identity<typename sprout::types::apply<sprout::types::pop_front_types<Tuple>, Types...>::type volatile>
|
||||||
|
{};
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Tuple>
|
||||||
|
struct pop_front_types<Tuple const volatile> {
|
||||||
|
public:
|
||||||
|
template<typename... Types>
|
||||||
|
struct apply
|
||||||
|
: public sprout::identity<typename sprout::types::apply<sprout::types::pop_front_types<Tuple>, Types...>::type const volatile>
|
||||||
|
{};
|
||||||
|
};
|
||||||
|
} // namespace types
|
||||||
|
|
||||||
|
using sprout::types::pop_front_types;
|
||||||
|
} // namespace sprout
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_TYPE_POP_FRONT_TYPES_HPP
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/type_traits/identity.hpp>
|
#include <sprout/type_traits/identity.hpp>
|
||||||
#include <sprout/index_tuple/index_t.hpp>
|
|
||||||
#include <sprout/type/apply.hpp>
|
#include <sprout/type/apply.hpp>
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
|
|
Loading…
Reference in a new issue