mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
sprout/tuple/* いろいろ追加
This commit is contained in:
parent
e11c2eb867
commit
c2b7bcd46b
13 changed files with 585 additions and 9 deletions
|
@ -53,6 +53,15 @@ namespace sprout {
|
|||
= std::tuple_size<typename std::remove_const<internal_type>::type>::value
|
||||
;
|
||||
};
|
||||
template<typename Container>
|
||||
struct fixed_container_traits<Container const>
|
||||
: public sprout::fixed_container_traits<Container>
|
||||
{
|
||||
public:
|
||||
typedef typename sprout::fixed_container_traits<Container>::const_iterator iterator;
|
||||
typedef typename sprout::fixed_container_traits<Container>::const_reference reference;
|
||||
typedef typename sprout::fixed_container_traits<Container>::const_pointer pointer;
|
||||
};
|
||||
template<typename T, std::size_t N>
|
||||
struct fixed_container_traits<T[N]>
|
||||
: public sprout::detail::fixed_container_traits_base<T[N]>
|
||||
|
@ -64,15 +73,6 @@ namespace sprout {
|
|||
public:
|
||||
SPROUT_STATIC_CONSTEXPR typename sprout::detail::fixed_container_traits_base<T[N]>::size_type fixed_size = N;
|
||||
};
|
||||
template<typename Container>
|
||||
struct fixed_container_traits<Container const>
|
||||
: public sprout::fixed_container_traits<Container>
|
||||
{
|
||||
public:
|
||||
typedef typename sprout::fixed_container_traits<Container>::const_iterator iterator;
|
||||
typedef typename sprout::fixed_container_traits<Container>::const_reference reference;
|
||||
typedef typename sprout::fixed_container_traits<Container>::const_pointer pointer;
|
||||
};
|
||||
template<typename T, std::size_t N>
|
||||
struct fixed_container_traits<T const[N]>
|
||||
: public sprout::fixed_container_traits<T[N]>
|
||||
|
|
6
sprout/tuple/algorithm.hpp
Normal file
6
sprout/tuple/algorithm.hpp
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef SPROUT_TUPLE_ALGORITHM_HPP
|
||||
#define SPROUT_TUPLE_ALGORITHM_HPP
|
||||
|
||||
#include <sprout/tuple/algorithm/copy.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_ALGORITHM_HPP
|
89
sprout/tuple/algorithm/copy.hpp
Normal file
89
sprout/tuple/algorithm/copy.hpp
Normal file
|
@ -0,0 +1,89 @@
|
|||
#ifndef SPROUT_TUPLE_ALGORITHM_COPY_HPP
|
||||
#define SPROUT_TUPLE_ALGORITHM_COPY_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple.hpp>
|
||||
#include <sprout/tuple/traits.hpp>
|
||||
#include <sprout/tuple/functions.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
namespace result_of {
|
||||
//
|
||||
// copy
|
||||
//
|
||||
template<typename Tuple, typename InputTuple>
|
||||
struct copy {
|
||||
public:
|
||||
typedef typename sprout::tuples::tuple_traits<Tuple>::clone_type type;
|
||||
};
|
||||
} // namespace result_of
|
||||
|
||||
namespace detail {
|
||||
template<typename Result, typename Tuple, typename InputTuple, std::ptrdiff_t... Indexes1, std::ptrdiff_t... Indexes2>
|
||||
SPROUT_CONSTEXPR inline Result copy_impl(
|
||||
Tuple const& t,
|
||||
InputTuple const& input,
|
||||
sprout::index_tuple<Indexes1...>,
|
||||
sprout::index_tuple<Indexes2...>
|
||||
)
|
||||
{
|
||||
return sprout::tuples::remake_clone<Result>(
|
||||
t,
|
||||
sprout::tuples::get<Indexes2>(input)...,
|
||||
sprout::tuples::get<Indexes1>(t)...
|
||||
);
|
||||
}
|
||||
template<typename Tuple, typename InputTuple>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::tuples::tuple_size<Tuple>::value > sprout::tuples::tuple_size<InputTuple>::value),
|
||||
typename sprout::tuples::result_of::copy<Tuple, InputTuple>::type
|
||||
>::type copy(
|
||||
Tuple const& t,
|
||||
InputTuple const& input
|
||||
)
|
||||
{
|
||||
return sprout::tuples::detail::copy_impl<typename sprout::tuples::result_of::copy<Tuple, InputTuple>::type>(
|
||||
t,
|
||||
input,
|
||||
typename sprout::index_range<sprout::tuples::tuple_size<InputTuple>::value, sprout::tuples::tuple_size<Tuple>::value>::type(),
|
||||
typename sprout::index_range<0, sprout::tuples::tuple_size<InputTuple>::value>::type()
|
||||
);
|
||||
}
|
||||
template<typename Tuple, typename InputTuple>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
!(sprout::tuples::tuple_size<Tuple>::value > sprout::tuples::tuple_size<InputTuple>::value),
|
||||
typename sprout::tuples::result_of::copy<Tuple, InputTuple>::type
|
||||
>::type copy(
|
||||
Tuple const& t,
|
||||
InputTuple const& input
|
||||
)
|
||||
{
|
||||
return sprout::tuples::detail::copy_impl<typename sprout::tuples::result_of::copy<Tuple, InputTuple>::type>(
|
||||
t,
|
||||
input,
|
||||
sprout::index_tuple<>(),
|
||||
typename sprout::index_range<0, sprout::tuples::tuple_size<Tuple>::value>::type()
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// copy
|
||||
//
|
||||
template<typename Tuple, typename InputTuple>
|
||||
SPROUT_CONSTEXPR inline typename sprout::tuples::result_of::copy<Tuple, InputTuple>::type copy(
|
||||
Tuple const& t,
|
||||
InputTuple const& input
|
||||
)
|
||||
{
|
||||
return sprout::tuples::detail::copy(
|
||||
t,
|
||||
input
|
||||
);
|
||||
}
|
||||
} // namespace tuples
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_ALGORITHM_COPY_HPP
|
24
sprout/tuple/clone.hpp
Normal file
24
sprout/tuple/clone.hpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef SPROUT_TUPLE_CLONE_HPP
|
||||
#define SPROUT_TUPLE_CLONE_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/tuple/traits.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
//
|
||||
// clone
|
||||
//
|
||||
template<typename Tuple>
|
||||
SPROUT_CONSTEXPR inline typename sprout::tuples::tuple_traits<
|
||||
typename std::remove_reference<Tuple>::type
|
||||
>::clone_type clone(Tuple&& cont) {
|
||||
typedef typename std::decay<Tuple>::type tuple_type;
|
||||
return sprout::tuples::clone_functor<tuple_type>().template operator()(sprout::forward<Tuple>(cont));
|
||||
}
|
||||
} // namespace tuples
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_CLONE_HPP
|
8
sprout/tuple/functions.hpp
Normal file
8
sprout/tuple/functions.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef SPROUT_TUPLE_FUNCTIONS_HPP
|
||||
#define SPROUT_TUPLE_FUNCTIONS_HPP
|
||||
|
||||
#include <sprout/tuple/clone.hpp>
|
||||
#include <sprout/tuple/make_clone.hpp>
|
||||
#include <sprout/tuple/remake_clone.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_FUNCTIONS_HPP
|
24
sprout/tuple/make_clone.hpp
Normal file
24
sprout/tuple/make_clone.hpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef SPROUT_TUPLE_MAKE_CLONE_HPP
|
||||
#define SPROUT_TUPLE_MAKE_CLONE_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/tuple/traits.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
//
|
||||
// make_clone
|
||||
//
|
||||
template<typename Tuple, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename sprout::tuples::tuple_traits<
|
||||
typename std::remove_reference<Tuple>::type
|
||||
>::clone_type make_clone(Args&&... args) {
|
||||
typedef typename std::remove_reference<Tuple>::type tuple_type;
|
||||
return sprout::tuples::make_clone_functor<tuple_type>().template operator()(sprout::forward<Args>(args)...);
|
||||
}
|
||||
} // namespace tuples
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_MAKE_CLONE_HPP
|
9
sprout/tuple/operation.hpp
Normal file
9
sprout/tuple/operation.hpp
Normal file
|
@ -0,0 +1,9 @@
|
|||
#ifndef SPROUT_TUPLE_OPERATION_HPP
|
||||
#define SPROUT_TUPLE_OPERATION_HPP
|
||||
|
||||
#include <sprout/tuple/operation/append_back.hpp>
|
||||
#include <sprout/tuple/operation/append_front.hpp>
|
||||
#include <sprout/tuple/operation/push_back.hpp>
|
||||
#include <sprout/tuple/operation/push_front.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_OPERATION_HPP
|
73
sprout/tuple/operation/append_back.hpp
Normal file
73
sprout/tuple/operation/append_back.hpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
#ifndef SPROUT_TUPLE_OPERATION_APPEND_BACK_HPP
|
||||
#define SPROUT_TUPLE_OPERATION_APPEND_BACK_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple.hpp>
|
||||
#include <sprout/tuple/traits.hpp>
|
||||
#include <sprout/tuple/functions.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
namespace result_of {
|
||||
//
|
||||
// append_back
|
||||
//
|
||||
template<typename Tuple, typename InputTuple>
|
||||
struct append_back {
|
||||
private:
|
||||
template<typename IndexTuple1, typename IndexTuple2>
|
||||
struct apply_impl;
|
||||
template<std::ptrdiff_t... Indexes1, std::ptrdiff_t... Indexes2>
|
||||
struct apply_impl<sprout::index_tuple<Indexes1...>, sprout::index_tuple<Indexes2...> >
|
||||
: public sprout::tuples::rebind_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
typename sprout::tuples::tuple_element<Indexes1, Tuple>::type...,
|
||||
typename sprout::tuples::tuple_element<Indexes2, InputTuple>::type...
|
||||
>
|
||||
{};
|
||||
public:
|
||||
typedef typename apply_impl<
|
||||
typename sprout::index_range<0, sprout::tuples::tuple_size<Tuple>::value>::type,
|
||||
typename sprout::index_range<0, sprout::tuples::tuple_size<InputTuple>::value>::type
|
||||
>::type type;
|
||||
};
|
||||
} // namespace result_of
|
||||
|
||||
namespace detail {
|
||||
template<typename Result, typename Tuple, typename InputTuple, std::ptrdiff_t... Indexes1, std::ptrdiff_t... Indexes2>
|
||||
SPROUT_CONSTEXPR inline Result append_back_impl(
|
||||
Tuple const& t,
|
||||
InputTuple const& input,
|
||||
sprout::index_tuple<Indexes1...>,
|
||||
sprout::index_tuple<Indexes2...>
|
||||
)
|
||||
{
|
||||
return sprout::tuples::remake_clone<Result>(
|
||||
t,
|
||||
sprout::tuples::get<Indexes1>(t)...,
|
||||
sprout::tuples::get<Indexes2>(input)...
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// append_back
|
||||
//
|
||||
template<typename Tuple, typename InputTuple>
|
||||
SPROUT_CONSTEXPR inline typename sprout::tuples::result_of::append_back<Tuple, InputTuple>::type append_back(
|
||||
Tuple const& t,
|
||||
InputTuple const& input
|
||||
)
|
||||
{
|
||||
return sprout::tuples::detail::append_back_impl<typename sprout::tuples::result_of::append_back<Tuple, InputTuple>::type>(
|
||||
t,
|
||||
input,
|
||||
typename sprout::index_range<0, sprout::tuples::tuple_size<Tuple>::value>::type(),
|
||||
typename sprout::index_range<0, sprout::tuples::tuple_size<InputTuple>::value>::type()
|
||||
);
|
||||
}
|
||||
} // namespace tuples
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_OPERATION_APPEND_BACK_HPP
|
73
sprout/tuple/operation/append_front.hpp
Normal file
73
sprout/tuple/operation/append_front.hpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
#ifndef SPROUT_TUPLE_OPERATION_APPEND_FRONT_HPP
|
||||
#define SPROUT_TUPLE_OPERATION_APPEND_FRONT_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple.hpp>
|
||||
#include <sprout/tuple/traits.hpp>
|
||||
#include <sprout/tuple/functions.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
namespace result_of {
|
||||
//
|
||||
// append_front
|
||||
//
|
||||
template<typename Tuple, typename InputTuple>
|
||||
struct append_front {
|
||||
private:
|
||||
template<typename IndexTuple1, typename IndexTuple2>
|
||||
struct apply_impl;
|
||||
template<std::ptrdiff_t... Indexes1, std::ptrdiff_t... Indexes2>
|
||||
struct apply_impl<sprout::index_tuple<Indexes1...>, sprout::index_tuple<Indexes2...> >
|
||||
: public sprout::tuples::rebind_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
typename sprout::tuples::tuple_element<Indexes2, InputTuple>::type...,
|
||||
typename sprout::tuples::tuple_element<Indexes1, Tuple>::type...
|
||||
>
|
||||
{};
|
||||
public:
|
||||
typedef typename apply_impl<
|
||||
typename sprout::index_range<0, sprout::tuples::tuple_size<Tuple>::value>::type,
|
||||
typename sprout::index_range<0, sprout::tuples::tuple_size<InputTuple>::value>::type
|
||||
>::type type;
|
||||
};
|
||||
} // namespace result_of
|
||||
|
||||
namespace detail {
|
||||
template<typename Result, typename Tuple, typename InputTuple, std::ptrdiff_t... Indexes1, std::ptrdiff_t... Indexes2>
|
||||
SPROUT_CONSTEXPR inline Result append_front_impl(
|
||||
Tuple const& t,
|
||||
InputTuple const& input,
|
||||
sprout::index_tuple<Indexes1...>,
|
||||
sprout::index_tuple<Indexes2...>
|
||||
)
|
||||
{
|
||||
return sprout::tuples::remake_clone<Result>(
|
||||
t,
|
||||
sprout::tuples::get<Indexes2>(input)...,
|
||||
sprout::tuples::get<Indexes1>(t)...
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// append_front
|
||||
//
|
||||
template<typename Tuple, typename InputTuple>
|
||||
SPROUT_CONSTEXPR inline typename sprout::tuples::result_of::append_front<Tuple, InputTuple>::type append_front(
|
||||
Tuple const& t,
|
||||
InputTuple const& input
|
||||
)
|
||||
{
|
||||
return sprout::tuples::detail::append_front_impl<typename sprout::tuples::result_of::append_front<Tuple, InputTuple>::type>(
|
||||
t,
|
||||
input,
|
||||
typename sprout::index_range<0, sprout::tuples::tuple_size<Tuple>::value>::type(),
|
||||
typename sprout::index_range<0, sprout::tuples::tuple_size<InputTuple>::value>::type()
|
||||
);
|
||||
}
|
||||
} // namespace tuples
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_OPERATION_APPEND_FRONT_HPP
|
70
sprout/tuple/operation/push_back.hpp
Normal file
70
sprout/tuple/operation/push_back.hpp
Normal file
|
@ -0,0 +1,70 @@
|
|||
#ifndef SPROUT_TUPLE_OPERATION_PUSH_BACK_HPP
|
||||
#define SPROUT_TUPLE_OPERATION_PUSH_BACK_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple.hpp>
|
||||
#include <sprout/tuple/traits.hpp>
|
||||
#include <sprout/tuple/functions.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
namespace result_of {
|
||||
//
|
||||
// push_back
|
||||
//
|
||||
template<typename Tuple, typename T>
|
||||
struct push_back {
|
||||
private:
|
||||
template<typename IndexTuple>
|
||||
struct apply_impl;
|
||||
template<std::ptrdiff_t... Indexes>
|
||||
struct apply_impl<sprout::index_tuple<Indexes...>>
|
||||
: public sprout::tuples::rebind_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
typename sprout::tuples::tuple_element<Indexes, Tuple>::type...,
|
||||
T
|
||||
>
|
||||
{};
|
||||
public:
|
||||
typedef typename apply_impl<
|
||||
typename sprout::index_range<0, sprout::tuples::tuple_size<Tuple>::value>::type
|
||||
>::type type;
|
||||
};
|
||||
} // namespace result_of
|
||||
|
||||
namespace detail {
|
||||
template<typename Result, typename Tuple, typename T, std::ptrdiff_t... Indexes>
|
||||
SPROUT_CONSTEXPR inline Result push_back_impl(
|
||||
Tuple const& t,
|
||||
T const& v,
|
||||
sprout::index_tuple<Indexes...>
|
||||
)
|
||||
{
|
||||
return sprout::tuples::remake_clone<Result>(
|
||||
t,
|
||||
sprout::tuples::get<Indexes>(t)...,
|
||||
v
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// push_back
|
||||
//
|
||||
template<typename Tuple, typename T>
|
||||
SPROUT_CONSTEXPR inline typename sprout::tuples::result_of::push_back<Tuple, T>::type push_back(
|
||||
Tuple const& t,
|
||||
T const& v
|
||||
)
|
||||
{
|
||||
return sprout::tuples::detail::push_back_impl<typename sprout::tuples::result_of::push_back<Tuple, T>::type>(
|
||||
t,
|
||||
v,
|
||||
typename sprout::index_range<0, sprout::tuples::tuple_size<Tuple>::value>::type()
|
||||
);
|
||||
}
|
||||
} // namespace tuples
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_OPERATION_PUSH_BACK_HPP
|
70
sprout/tuple/operation/push_front.hpp
Normal file
70
sprout/tuple/operation/push_front.hpp
Normal file
|
@ -0,0 +1,70 @@
|
|||
#ifndef SPROUT_TUPLE_OPERATION_PUSH_FRONT_HPP
|
||||
#define SPROUT_TUPLE_OPERATION_PUSH_FRONT_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple.hpp>
|
||||
#include <sprout/tuple/traits.hpp>
|
||||
#include <sprout/tuple/functions.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
namespace result_of {
|
||||
//
|
||||
// push_front
|
||||
//
|
||||
template<typename Tuple, typename T>
|
||||
struct push_front {
|
||||
private:
|
||||
template<typename IndexTuple>
|
||||
struct apply_impl;
|
||||
template<std::ptrdiff_t... Indexes>
|
||||
struct apply_impl<sprout::index_tuple<Indexes...>>
|
||||
: public sprout::tuples::rebind_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
T,
|
||||
typename sprout::tuples::tuple_element<Indexes, Tuple>::type...
|
||||
>
|
||||
{};
|
||||
public:
|
||||
typedef typename apply_impl<
|
||||
typename sprout::index_range<0, sprout::tuples::tuple_size<Tuple>::value>::type
|
||||
>::type type;
|
||||
};
|
||||
} // namespace result_of
|
||||
|
||||
namespace detail {
|
||||
template<typename Result, typename Tuple, typename T, std::ptrdiff_t... Indexes>
|
||||
SPROUT_CONSTEXPR inline Result push_front_impl(
|
||||
Tuple const& t,
|
||||
T const& v,
|
||||
sprout::index_tuple<Indexes...>
|
||||
)
|
||||
{
|
||||
return sprout::tuples::remake_clone<Result>(
|
||||
t,
|
||||
v,
|
||||
sprout::tuples::get<Indexes>(t)...
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// push_front
|
||||
//
|
||||
template<typename Tuple, typename T>
|
||||
SPROUT_CONSTEXPR inline typename sprout::tuples::result_of::push_front<Tuple, T>::type push_front(
|
||||
Tuple const& t,
|
||||
T const& v
|
||||
)
|
||||
{
|
||||
return sprout::tuples::detail::push_front_impl<typename sprout::tuples::result_of::push_front<Tuple, T>::type>(
|
||||
t,
|
||||
v,
|
||||
typename sprout::index_range<0, sprout::tuples::tuple_size<Tuple>::value>::type()
|
||||
);
|
||||
}
|
||||
} // namespace tuples
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_OPERATION_PUSH_FRONT_HPP
|
31
sprout/tuple/remake_clone.hpp
Normal file
31
sprout/tuple/remake_clone.hpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#ifndef SPROUT_TUPLE_REMAKE_CLONE_HPP
|
||||
#define SPROUT_TUPLE_REMAKE_CLONE_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/tuple/traits.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
//
|
||||
// remake_clone
|
||||
//
|
||||
template<typename Tuple, typename Other, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename sprout::tuples::tuple_traits<
|
||||
typename std::remove_reference<Tuple>::type
|
||||
>::clone_type remake_clone(
|
||||
Other&& other,
|
||||
Args&&... args
|
||||
)
|
||||
{
|
||||
typedef typename std::remove_reference<Tuple>::type tuple_type;
|
||||
return sprout::tuples::remake_clone_functor<tuple_type>().template operator()(
|
||||
sprout::forward<Other>(other),
|
||||
sprout::forward<Args>(args)...
|
||||
);
|
||||
}
|
||||
} // namespace tuples
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_REMAKE_CLONE_HPP
|
99
sprout/tuple/traits.hpp
Normal file
99
sprout/tuple/traits.hpp
Normal file
|
@ -0,0 +1,99 @@
|
|||
#ifndef SPROUT_TUPLE_TRAITS_HPP
|
||||
#define SPROUT_TUPLE_TRAITS_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
//
|
||||
// tuple_traits
|
||||
//
|
||||
template<typename Tuple>
|
||||
struct tuple_traits {
|
||||
public:
|
||||
typedef Tuple internal_type;
|
||||
typedef Tuple clone_type;
|
||||
};
|
||||
template<typename Tuple>
|
||||
struct tuple_traits<Tuple const>
|
||||
: public sprout::tuples::tuple_traits<Tuple>
|
||||
{};
|
||||
|
||||
//
|
||||
// rebind_types
|
||||
//
|
||||
template<typename Tuple>
|
||||
struct rebind_types {
|
||||
public:
|
||||
template<typename... Types>
|
||||
struct apply;
|
||||
};
|
||||
template<typename... Ts>
|
||||
struct rebind_types<sprout::tuples::tuple<Ts...> > {
|
||||
public:
|
||||
template<typename... Types>
|
||||
struct apply {
|
||||
public:
|
||||
typedef sprout::tuples::tuple<Types...> type;
|
||||
};
|
||||
};
|
||||
|
||||
//
|
||||
// clone_functor
|
||||
//
|
||||
template<typename Tuple>
|
||||
struct clone_functor {
|
||||
public:
|
||||
template<typename Other>
|
||||
SPROUT_CONSTEXPR typename sprout::tuples::tuple_traits<Tuple>::clone_type operator()(Other&& t) const {
|
||||
return typename sprout::tuples::tuple_traits<Tuple>::clone_type(sprout::forward<Other>(t));
|
||||
}
|
||||
};
|
||||
template<typename Tuple>
|
||||
struct clone_functor<Tuple const>
|
||||
: public sprout::tuples::clone_functor<Tuple>
|
||||
{};
|
||||
|
||||
//
|
||||
// make_clone_functor
|
||||
//
|
||||
template<typename Tuple>
|
||||
struct make_clone_functor {
|
||||
public:
|
||||
template<typename... Args>
|
||||
SPROUT_CONSTEXPR typename sprout::tuples::tuple_traits<Tuple>::clone_type operator()(Args&&... args) const {
|
||||
return typename sprout::tuples::tuple_traits<Tuple>::clone_type(sprout::forward<Args>(args)...);
|
||||
}
|
||||
};
|
||||
template<typename Tuple>
|
||||
struct make_clone_functor<Tuple const>
|
||||
: public sprout::tuples::make_clone_functor<Tuple>
|
||||
{};
|
||||
|
||||
//
|
||||
// remake_clone_functor
|
||||
//
|
||||
template<typename Tuple>
|
||||
struct remake_clone_functor {
|
||||
public:
|
||||
template<typename Other, typename... Args>
|
||||
SPROUT_CONSTEXPR typename sprout::tuples::tuple_traits<Tuple>::clone_type operator()(
|
||||
Other&& other,
|
||||
Args&&... args
|
||||
) const
|
||||
{
|
||||
return sprout::tuples::make_clone_functor<Tuple>().template operator()(sprout::forward<Args>(args)...);
|
||||
}
|
||||
};
|
||||
template<typename Tuple>
|
||||
struct remake_clone_functor<Tuple const>
|
||||
: public sprout::tuples::remake_clone_functor<Tuple>
|
||||
{};
|
||||
} // namespace tuples
|
||||
|
||||
using sprout::tuples::tuple_traits;
|
||||
using sprout::tuples::rebind_types;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_TRAITS_HPP
|
Loading…
Reference in a new issue