From 609f0b6f8ab935c08d1fdbf6627c9f49b1967d21 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Tue, 5 Aug 2014 19:32:40 +0900 Subject: [PATCH] add types::rebind, types::assign --- sprout/type/operation.hpp | 4 ++- sprout/type/operation/append_back.hpp | 33 ++++++------------------ sprout/type/operation/append_front.hpp | 35 ++++++++------------------ sprout/type/operation/assign.hpp | 35 ++++++++++++++++++++++++++ sprout/type/operation/push_back.hpp | 27 ++++---------------- sprout/type/operation/push_front.hpp | 29 ++++++--------------- sprout/type/operation/rebind.hpp | 31 +++++++++++++++++++++++ sprout/type/type_tuple.hpp | 19 -------------- 8 files changed, 99 insertions(+), 114 deletions(-) create mode 100644 sprout/type/operation/assign.hpp create mode 100644 sprout/type/operation/rebind.hpp diff --git a/sprout/type/operation.hpp b/sprout/type/operation.hpp index 369826d8..f4823f33 100644 --- a/sprout/type/operation.hpp +++ b/sprout/type/operation.hpp @@ -9,7 +9,6 @@ #define SPROUT_TYPE_OPERATION_HPP #include -#include #include #include #include @@ -21,5 +20,8 @@ #include #include #include +#include +#include +#include #endif // #ifndef SPROUT_TYPE_OPERATION_HPP diff --git a/sprout/type/operation/append_back.hpp b/sprout/type/operation/append_back.hpp index 5b7502f9..a564dee2 100644 --- a/sprout/type/operation/append_back.hpp +++ b/sprout/type/operation/append_back.hpp @@ -9,40 +9,21 @@ #define SPROUT_TYPE_OPERATION_APPEND_BACK_HPP #include -#include -#include -#include -#include +#include namespace sprout { namespace types { // // append_back // - template - struct append_back { - private: - template - struct apply_impl; - template - struct apply_impl, sprout::index_tuple > - : public sprout::types::rebind_types< - Tuple - >::template apply< - typename sprout::types::tuple_element::type..., - typename sprout::types::tuple_element::type... - > - {}; - public: - typedef typename apply_impl< - typename sprout::tuple_indexes::type, - typename sprout::tuple_indexes::type - >::type type; - }; + template + struct append_back + : public sprout::types::tuple_cat + {}; #if SPROUT_USE_TEMPLATE_ALIASES - template - using append_back_t = typename sprout::types::append_back::type; + template + using append_back_t = typename sprout::types::append_back::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace types } // namespace sprout diff --git a/sprout/type/operation/append_front.hpp b/sprout/type/operation/append_front.hpp index e51e59d8..13402105 100644 --- a/sprout/type/operation/append_front.hpp +++ b/sprout/type/operation/append_front.hpp @@ -9,40 +9,25 @@ #define SPROUT_TYPE_OPERATION_APPEND_FRONT_HPP #include -#include -#include #include -#include +#include namespace sprout { namespace types { // // append_front // - template - struct append_front { - private: - template - struct apply_impl; - template - struct apply_impl, sprout::index_tuple > - : public sprout::types::rebind_types< - Tuple - >::template apply< - typename sprout::types::tuple_element::type..., - typename sprout::types::tuple_element::type... - > - {}; - public: - typedef typename apply_impl< - typename sprout::tuple_indexes::type, - typename sprout::tuple_indexes::type - >::type type; - }; + template + struct append_front + : public sprout::types::tuple_cat< + typename sprout::types::rebind_types::template apply<>::type, + InputTuples..., Tuple + > + {}; #if SPROUT_USE_TEMPLATE_ALIASES - template - using append_front_t = typename sprout::types::append_front::type; + template + using append_front_t = typename sprout::types::append_front::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace types } // namespace sprout diff --git a/sprout/type/operation/assign.hpp b/sprout/type/operation/assign.hpp new file mode 100644 index 00000000..0b1cfa81 --- /dev/null +++ b/sprout/type/operation/assign.hpp @@ -0,0 +1,35 @@ +/*============================================================================= + 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_ASSIGN_HPP +#define SPROUT_TYPE_OPERATION_ASSIGN_HPP + +#include +#include +#include + +namespace sprout { + namespace types { + // + // assign + // + template + struct assign + : public sprout::types::tuple_cat< + typename sprout::types::rebind_types::template apply<>::type, + InputTuple + > + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using assign_t = typename sprout::types::assign::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_OPERATION_ASSIGN_HPP diff --git a/sprout/type/operation/push_back.hpp b/sprout/type/operation/push_back.hpp index 1cbb0d6a..96119ce6 100644 --- a/sprout/type/operation/push_back.hpp +++ b/sprout/type/operation/push_back.hpp @@ -9,10 +9,8 @@ #define SPROUT_TYPE_OPERATION_PUSH_BACK_HPP #include -#include -#include -#include -#include +#include +#include namespace sprout { namespace types { @@ -20,24 +18,9 @@ namespace sprout { // push_back // template - struct push_back { - private: - template - struct apply_impl; - template - struct apply_impl > - : public sprout::types::rebind_types< - Tuple - >::template apply< - typename sprout::types::tuple_element::type..., - Ts... - > - {}; - public: - typedef typename apply_impl< - typename sprout::tuple_indexes::type - >::type type; - }; + struct push_back + : public sprout::types::tuple_cat > + {}; #if SPROUT_USE_TEMPLATE_ALIASES template diff --git a/sprout/type/operation/push_front.hpp b/sprout/type/operation/push_front.hpp index 34bc4396..2a8447ea 100644 --- a/sprout/type/operation/push_front.hpp +++ b/sprout/type/operation/push_front.hpp @@ -9,10 +9,9 @@ #define SPROUT_TYPE_OPERATION_PUSH_FRONT_HPP #include -#include -#include #include -#include +#include +#include namespace sprout { namespace types { @@ -20,24 +19,12 @@ namespace sprout { // push_front // template - struct push_front { - private: - template - struct apply_impl; - template - struct apply_impl > - : public sprout::types::rebind_types< - Tuple - >::template apply< - Ts..., - typename sprout::types::tuple_element::type... - > - {}; - public: - typedef typename apply_impl< - typename sprout::tuple_indexes::type - >::type type; - }; + struct push_front + : public sprout::types::tuple_cat< + typename sprout::types::rebind_types::template apply<>::type, + sprout::types::type_tuple, Tuple + > + {}; #if SPROUT_USE_TEMPLATE_ALIASES template diff --git a/sprout/type/operation/rebind.hpp b/sprout/type/operation/rebind.hpp new file mode 100644 index 00000000..4cbd89ce --- /dev/null +++ b/sprout/type/operation/rebind.hpp @@ -0,0 +1,31 @@ +/*============================================================================= + 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_REBIND_HPP +#define SPROUT_TYPE_OPERATION_REBIND_HPP + +#include +#include + +namespace sprout { + namespace types { + // + // rebind + // + template + struct rebind + : public sprout::types::rebind_types::template apply + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using rebind_t = typename sprout::types::rebind::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_OPERATION_REBIND_HPP diff --git a/sprout/type/type_tuple.hpp b/sprout/type/type_tuple.hpp index afa8e67d..9449baf3 100644 --- a/sprout/type/type_tuple.hpp +++ b/sprout/type/type_tuple.hpp @@ -218,25 +218,6 @@ namespace sprout { struct pop_front > : public sprout::identity > {}; - - // - // append_back - // - template - struct append_back; - template - struct append_back > - : public sprout::types::push_back - {}; - // - // append_front - // - template - struct append_front; - template - struct append_front > - : public sprout::types::push_front - {}; } // namespace types } // namespace sprout