mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2024-11-12 21:09:01 +00:00
add types::rebind, types::assign
This commit is contained in:
parent
58b0390679
commit
609f0b6f8a
8 changed files with 99 additions and 114 deletions
|
@ -9,7 +9,6 @@
|
|||
#define SPROUT_TYPE_OPERATION_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type/operation/tuple_cat.hpp>
|
||||
#include <sprout/type/operation/size.hpp>
|
||||
#include <sprout/type/operation/empty.hpp>
|
||||
#include <sprout/type/operation/at.hpp>
|
||||
|
@ -21,5 +20,8 @@
|
|||
#include <sprout/type/operation/push_front.hpp>
|
||||
#include <sprout/type/operation/pop_back.hpp>
|
||||
#include <sprout/type/operation/pop_front.hpp>
|
||||
#include <sprout/type/operation/tuple_cat.hpp>
|
||||
#include <sprout/type/operation/rebind.hpp>
|
||||
#include <sprout/type/operation/assign.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_OPERATION_HPP
|
||||
|
|
|
@ -9,40 +9,21 @@
|
|||
#define SPROUT_TYPE_OPERATION_APPEND_BACK_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple/metafunction.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
#include <sprout/tuple/indexes.hpp>
|
||||
#include <sprout/type/operation/tuple_cat.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace types {
|
||||
//
|
||||
// append_back
|
||||
//
|
||||
template<typename Tuple, typename InputTuple>
|
||||
struct append_back {
|
||||
private:
|
||||
template<typename IndexTuple1, typename IndexTuple2>
|
||||
struct apply_impl;
|
||||
template<sprout::index_t... Indexes1, sprout::index_t... Indexes2>
|
||||
struct apply_impl<sprout::index_tuple<Indexes1...>, sprout::index_tuple<Indexes2...> >
|
||||
: public sprout::types::rebind_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
typename sprout::types::tuple_element<Indexes1, Tuple>::type...,
|
||||
typename sprout::types::tuple_element<Indexes2, InputTuple>::type...
|
||||
>
|
||||
template<typename Tuple, typename... InputTuples>
|
||||
struct append_back
|
||||
: public sprout::types::tuple_cat<Tuple, InputTuples...>
|
||||
{};
|
||||
public:
|
||||
typedef typename apply_impl<
|
||||
typename sprout::tuple_indexes<Tuple>::type,
|
||||
typename sprout::tuple_indexes<InputTuple>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename Tuple, typename InputTuple>
|
||||
using append_back_t = typename sprout::types::append_back<Tuple, InputTuple>::type;
|
||||
template<typename Tuple, typename... InputTuples>
|
||||
using append_back_t = typename sprout::types::append_back<Tuple, InputTuples...>::type;
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
} // namespace types
|
||||
} // namespace sprout
|
||||
|
|
|
@ -9,40 +9,25 @@
|
|||
#define SPROUT_TYPE_OPERATION_APPEND_FRONT_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple/metafunction.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
#include <sprout/tuple/indexes.hpp>
|
||||
#include <sprout/type/operation/tuple_cat.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace types {
|
||||
//
|
||||
// append_front
|
||||
//
|
||||
template<typename Tuple, typename InputTuple>
|
||||
struct append_front {
|
||||
private:
|
||||
template<typename IndexTuple1, typename IndexTuple2>
|
||||
struct apply_impl;
|
||||
template<sprout::index_t... Indexes1, sprout::index_t... Indexes2>
|
||||
struct apply_impl<sprout::index_tuple<Indexes1...>, sprout::index_tuple<Indexes2...> >
|
||||
: public sprout::types::rebind_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
typename sprout::types::tuple_element<Indexes2, InputTuple>::type...,
|
||||
typename sprout::types::tuple_element<Indexes1, Tuple>::type...
|
||||
template<typename Tuple, typename... InputTuples>
|
||||
struct append_front
|
||||
: public sprout::types::tuple_cat<
|
||||
typename sprout::types::rebind_types<Tuple>::template apply<>::type,
|
||||
InputTuples..., Tuple
|
||||
>
|
||||
{};
|
||||
public:
|
||||
typedef typename apply_impl<
|
||||
typename sprout::tuple_indexes<Tuple>::type,
|
||||
typename sprout::tuple_indexes<InputTuple>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename Tuple, typename InputTuple>
|
||||
using append_front_t = typename sprout::types::append_front<Tuple, InputTuple>::type;
|
||||
template<typename Tuple, typename... InputTuples>
|
||||
using append_front_t = typename sprout::types::append_front<Tuple, InputTuples...>::type;
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
} // namespace types
|
||||
} // namespace sprout
|
||||
|
|
35
sprout/type/operation/assign.hpp
Normal file
35
sprout/type/operation/assign.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
#include <sprout/type/operation/tuple_cat.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace types {
|
||||
//
|
||||
// assign
|
||||
//
|
||||
template<typename Tuple, typename InputTuple>
|
||||
struct assign
|
||||
: public sprout::types::tuple_cat<
|
||||
typename sprout::types::rebind_types<Tuple>::template apply<>::type,
|
||||
InputTuple
|
||||
>
|
||||
{};
|
||||
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename Tuple, typename InputTuple>
|
||||
using assign_t = typename sprout::types::assign<Tuple, InputTuple>::type;
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
} // namespace types
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_OPERATION_ASSIGN_HPP
|
|
@ -9,10 +9,8 @@
|
|||
#define SPROUT_TYPE_OPERATION_PUSH_BACK_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple/metafunction.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
#include <sprout/tuple/indexes.hpp>
|
||||
#include <sprout/type/type_tuple.hpp>
|
||||
#include <sprout/type/operation/tuple_cat.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace types {
|
||||
|
@ -20,24 +18,9 @@ namespace sprout {
|
|||
// push_back
|
||||
//
|
||||
template<typename Tuple, typename... Ts>
|
||||
struct push_back {
|
||||
private:
|
||||
template<typename IndexTuple>
|
||||
struct apply_impl;
|
||||
template<sprout::index_t... Indexes>
|
||||
struct apply_impl<sprout::index_tuple<Indexes...> >
|
||||
: public sprout::types::rebind_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
typename sprout::types::tuple_element<Indexes, Tuple>::type...,
|
||||
Ts...
|
||||
>
|
||||
struct push_back
|
||||
: public sprout::types::tuple_cat<Tuple, sprout::types::type_tuple<Ts...> >
|
||||
{};
|
||||
public:
|
||||
typedef typename apply_impl<
|
||||
typename sprout::tuple_indexes<Tuple>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename Tuple, typename... Ts>
|
||||
|
|
|
@ -9,10 +9,9 @@
|
|||
#define SPROUT_TYPE_OPERATION_PUSH_FRONT_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple/metafunction.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
#include <sprout/tuple/indexes.hpp>
|
||||
#include <sprout/type/type_tuple.hpp>
|
||||
#include <sprout/type/operation/tuple_cat.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace types {
|
||||
|
@ -20,24 +19,12 @@ namespace sprout {
|
|||
// push_front
|
||||
//
|
||||
template<typename Tuple, typename... Ts>
|
||||
struct push_front {
|
||||
private:
|
||||
template<typename IndexTuple>
|
||||
struct apply_impl;
|
||||
template<sprout::index_t... Indexes>
|
||||
struct apply_impl<sprout::index_tuple<Indexes...> >
|
||||
: public sprout::types::rebind_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
Ts...,
|
||||
typename sprout::types::tuple_element<Indexes, Tuple>::type...
|
||||
struct push_front
|
||||
: public sprout::types::tuple_cat<
|
||||
typename sprout::types::rebind_types<Tuple>::template apply<>::type,
|
||||
sprout::types::type_tuple<Ts...>, Tuple
|
||||
>
|
||||
{};
|
||||
public:
|
||||
typedef typename apply_impl<
|
||||
typename sprout::tuple_indexes<Tuple>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename Tuple, typename... Ts>
|
||||
|
|
31
sprout/type/operation/rebind.hpp
Normal file
31
sprout/type/operation/rebind.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace types {
|
||||
//
|
||||
// rebind
|
||||
//
|
||||
template<typename Tuple, typename... Ts>
|
||||
struct rebind
|
||||
: public sprout::types::rebind_types<Tuple>::template apply<Ts...>
|
||||
{};
|
||||
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename Tuple, typename... Ts>
|
||||
using rebind_t = typename sprout::types::rebind<Tuple, Ts...>::type;
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
} // namespace types
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_OPERATION_REBIND_HPP
|
|
@ -218,25 +218,6 @@ namespace sprout {
|
|||
struct pop_front<sprout::types::type_tuple<Head, Tail...> >
|
||||
: public sprout::identity<sprout::types::type_tuple<Tail...> >
|
||||
{};
|
||||
|
||||
//
|
||||
// append_back
|
||||
//
|
||||
template<typename Tuple, typename InputTuple>
|
||||
struct append_back;
|
||||
template<typename Tuple, typename... InputTypes>
|
||||
struct append_back<Tuple, sprout::types::type_tuple<InputTypes...> >
|
||||
: public sprout::types::push_back<Tuple, InputTypes...>
|
||||
{};
|
||||
//
|
||||
// append_front
|
||||
//
|
||||
template<typename Tuple, typename InputTuple>
|
||||
struct append_front;
|
||||
template<typename Tuple, typename... InputTypes>
|
||||
struct append_front<Tuple, sprout::types::type_tuple<InputTypes...> >
|
||||
: public sprout::types::push_front<InputTypes..., Tuple>
|
||||
{};
|
||||
} // namespace types
|
||||
} // namespace sprout
|
||||
|
||||
|
|
Loading…
Reference in a new issue