From 8f5f023ed9a24c3e5a6eefa73d5c595a3bd88318 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Tue, 5 Aug 2014 10:57:37 +0900 Subject: [PATCH] add types::joint_types --- sprout/type.hpp | 2 + sprout/type/index_tuple.hpp | 56 ++++++++++++++++ sprout/type/joint_types.hpp | 124 +++++++++++++++++++++++++++++++++++ sprout/type/rebind_types.hpp | 26 +++++++- 4 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 sprout/type/index_tuple.hpp create mode 100644 sprout/type/joint_types.hpp diff --git a/sprout/type.hpp b/sprout/type.hpp index 4d36004a..320998ca 100644 --- a/sprout/type.hpp +++ b/sprout/type.hpp @@ -15,10 +15,12 @@ #include #include #include +#include #include #include #include #include #include +#include #endif // #ifndef SPROUT_TYPE_HPP diff --git a/sprout/type/index_tuple.hpp b/sprout/type/index_tuple.hpp new file mode 100644 index 00000000..f6bbd02f --- /dev/null +++ b/sprout/type/index_tuple.hpp @@ -0,0 +1,56 @@ +/*============================================================================= + 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_INDEX_TUPLE_HPP +#define SPROUT_TYPE_INDEX_TUPLE_HPP + +#include +#include +#include + +namespace sprout { + namespace types { + // + // rebind_types + // + template + struct rebind_types > { + public: + template + struct apply { + public: + typedef sprout::integer_sequence type; + }; + }; + +#if !(SPROUT_USE_TEMPLATE_ALIASES && !defined(SPROUT_WORKAROUND_NO_TEMPLATE_ARGUMENT_DEDUCTION_WITH_ALIASES)) + // + // rebind_types + // + template + struct rebind_types > { + public: + template + struct apply { + public: + typedef sprout::index_tuple type; + }; + }; + template + struct rebind_types > { + public: + template + struct apply { + public: + typedef sprout::uindex_tuple type; + }; + }; +#endif // #if !(SPROUT_USE_TEMPLATE_ALIASES && !defined(SPROUT_WORKAROUND_NO_TEMPLATE_ARGUMENT_DEDUCTION_WITH_ALIASES)) + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_INDEX_TUPLE_HPP diff --git a/sprout/type/joint_types.hpp b/sprout/type/joint_types.hpp new file mode 100644 index 00000000..7faa3c95 --- /dev/null +++ b/sprout/type/joint_types.hpp @@ -0,0 +1,124 @@ +/*============================================================================= + 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_JOINT_TYPES_HPP +#define SPROUT_TYPE_JOINT_TYPES_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace types { + namespace detail { + template + struct joint_types_impl { + 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 joint_types_default {}; + template class TupleClass, typename... Ts> + struct joint_types_default > { + public: + template + struct apply + : public sprout::types::detail::joint_types_impl, Tup> + {}; + template + struct apply > + : public sprout::identity > + {}; + }; + template class ValueTupleClass, typename T, T... Vs> + struct joint_types_default > { + public: + template + struct apply + : public sprout::types::detail::joint_types_impl, Tup> + {}; + template + struct apply > + : public sprout::identity > + {}; + }; + } // namespace detail + + // + // joint_types + // + template + struct joint_types + : public sprout::types::detail::joint_types_default + {}; + + template + struct joint_types { + public: + template + struct apply { + public: + typedef typename sprout::types::joint_types< + Tuple + >::template apply< + Tup + >::type const type; + }; + }; + + template + struct joint_types { + public: + template + struct apply { + public: + typedef typename sprout::types::joint_types< + Tuple + >::template apply< + Tup + >::type volatile type; + }; + }; + + template + struct joint_types { + public: + template + struct apply { + public: + typedef typename sprout::types::joint_types< + Tuple + >::template apply< + Tup + >::type const volatile type; + }; + }; + } // namespace types + + using sprout::types::joint_types; +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_JOINT_TYPES_HPP diff --git a/sprout/type/rebind_types.hpp b/sprout/type/rebind_types.hpp index 607f897f..7799c2be 100644 --- a/sprout/type/rebind_types.hpp +++ b/sprout/type/rebind_types.hpp @@ -9,14 +9,38 @@ #define SPROUT_TYPE_REBIND_TYPES_HPP #include +#include namespace sprout { namespace types { + namespace detail { + template + struct rebind_types_default {}; + template class TupleClass, typename... Ts> + struct rebind_types_default > { + public: + template + struct apply + : public sprout::identity > + {}; + }; + template class ValueTupleClass, typename T, T... Vs> + struct rebind_types_default > { + public: + template + struct apply + : public sprout::identity > + {}; + }; + } // namespace detail + // // rebind_types // template - struct rebind_types; + struct rebind_types + : public sprout::types::detail::rebind_types_default + {}; template struct rebind_types {