mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
add types::apply, types::quote
This commit is contained in:
parent
cb23ccdd55
commit
062058e614
26 changed files with 265 additions and 120 deletions
|
@ -20,7 +20,7 @@
|
|||
#include <sprout/tuple/tuple/tuple.hpp>
|
||||
#include <sprout/tuple/tuple/get.hpp>
|
||||
#include <sprout/tuple/tuple/make_tuple.hpp>
|
||||
#include <sprout/type/algorithm/find_index_if.hpp>
|
||||
#include <sprout/type/algorithm/contains_if.hpp>
|
||||
#include <sprout/type/algorithm/lower_bound_index.hpp>
|
||||
#include <sprout/type/type_tuple.hpp>
|
||||
#include <sprout/type/integral_array.hpp>
|
||||
|
@ -212,7 +212,7 @@ namespace sprout {
|
|||
struct is_variadic_bounds
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
(sprout::types::find_index_if<Bounds, sprout::detail::is_variadic_placeholder_pred>::value != sprout::tuples::tuple_size<Bounds>::value)
|
||||
sprout::types::contains_if<Bounds, sprout::detail::is_variadic_placeholder_pred>::value
|
||||
>
|
||||
{};
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <sprout/index_tuple/metafunction.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/tuple/indexes.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
|
||||
|
@ -36,7 +37,8 @@ namespace sprout {
|
|||
struct default_copied;
|
||||
template<typename Tuple, sprout::index_t... Indexes>
|
||||
struct default_copied<Tuple, sprout::index_tuple<Indexes...> >
|
||||
: public sprout::tuples::rebind_types<Tuple>::template apply<
|
||||
: public sprout::types::apply<
|
||||
sprout::tuples::rebind_types<Tuple>,
|
||||
typename std::decay<
|
||||
typename sprout::tuples::tuple_element<Indexes, Tuple>::type
|
||||
>::type...
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#define SPROUT_TYPE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
#include <sprout/type/quote.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
#include <sprout/type/type_tuple.hpp>
|
||||
#include <sprout/type/integral_array.hpp>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <sprout/type/algorithm/fold.hpp>
|
||||
#include <sprout/type/algorithm/transform.hpp>
|
||||
#include <sprout/type/algorithm/contains.hpp>
|
||||
#include <sprout/type/algorithm/contains_if.hpp>
|
||||
#include <sprout/type/algorithm/accumulate.hpp>
|
||||
#include <sprout/type/algorithm/partial_sum.hpp>
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
#include <sprout/type/algorithm/find_index.hpp>
|
||||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace types {
|
||||
|
@ -20,10 +19,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename Tuple, typename T>
|
||||
struct contains
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
sprout::types::find_index<Tuple, T>::value != sprout::types::tuple_size<Tuple>::value
|
||||
>
|
||||
: public sprout::types::find_index<Tuple, T>::found
|
||||
{};
|
||||
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
|
37
sprout/type/algorithm/contains_if.hpp
Normal file
37
sprout/type/algorithm/contains_if.hpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*=============================================================================
|
||||
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_ALGORITHM_CONTAINTS_IF_HPP
|
||||
#define SPROUT_TYPE_ALGORITHM_CONTAINTS_IF_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
#include <sprout/type/algorithm/find_index_if.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace types {
|
||||
//
|
||||
// contains_if
|
||||
//
|
||||
template<typename Tuple, typename Predicate>
|
||||
struct contains_if
|
||||
: public sprout::types::find_index_if<Tuple, Predicate>::found
|
||||
{};
|
||||
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename Tuple, typename Predicate>
|
||||
using contains_if_t = typename sprout::types::contains_if<Tuple, Predicate>::type;
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
||||
#if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
template<typename Tuple, typename Predicate>
|
||||
SPROUT_STATIC_CONSTEXPR bool contains_if_v = sprout::types::contains_if<Tuple, Predicate>::value;
|
||||
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
} // namespace types
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_ALGORITHM_CONTAINTS_IF_HPP
|
|
@ -17,24 +17,40 @@
|
|||
namespace sprout {
|
||||
namespace types {
|
||||
namespace detail {
|
||||
template<typename Tuple, typename T, std::size_t I, typename = void>
|
||||
template<
|
||||
typename Tuple, typename T, std::size_t I,
|
||||
bool Valid = (I != sprout::types::tuple_size<Tuple>::value),
|
||||
typename Enable = void
|
||||
>
|
||||
struct find_index_impl;
|
||||
template<typename Tuple, typename T, std::size_t I>
|
||||
struct find_index_impl<
|
||||
Tuple, T, I,
|
||||
Tuple, T, I, false,
|
||||
void
|
||||
>
|
||||
: public sprout::integral_constant<std::size_t, I>
|
||||
{
|
||||
public:
|
||||
typedef sprout::false_type found;
|
||||
};
|
||||
template<typename Tuple, typename T, std::size_t I>
|
||||
struct find_index_impl<
|
||||
Tuple, T, I, true,
|
||||
typename std::enable_if<
|
||||
I == sprout::types::tuple_size<Tuple>::value
|
||||
|| std::is_same<typename sprout::types::tuple_element<I, Tuple>::type, T>::value
|
||||
std::is_same<typename sprout::types::tuple_element<I, Tuple>::type, T>::value
|
||||
>::type
|
||||
>
|
||||
: public sprout::integral_constant<std::size_t, I>
|
||||
{};
|
||||
{
|
||||
public:
|
||||
typedef sprout::true_type found;
|
||||
typedef typename sprout::types::tuple_element<I, Tuple>::type element;
|
||||
};
|
||||
template<typename Tuple, typename T, std::size_t I>
|
||||
struct find_index_impl<
|
||||
Tuple, T, I,
|
||||
Tuple, T, I, true,
|
||||
typename std::enable_if<
|
||||
I != sprout::types::tuple_size<Tuple>::value
|
||||
&& !std::is_same<typename sprout::types::tuple_element<I, Tuple>::type, T>::value
|
||||
!std::is_same<typename sprout::types::tuple_element<I, Tuple>::type, T>::value
|
||||
>::type
|
||||
>
|
||||
: public sprout::types::detail::find_index_impl<Tuple, T, I + 1>
|
||||
|
|
|
@ -11,30 +11,47 @@
|
|||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/workaround/std/cstddef.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace types {
|
||||
namespace detail {
|
||||
template<typename Tuple, typename Predicate, std::size_t I, typename = void>
|
||||
template<
|
||||
typename Tuple, typename Predicate, std::size_t I,
|
||||
bool Valid = (I != sprout::types::tuple_size<Tuple>::value),
|
||||
typename Enable = void
|
||||
>
|
||||
struct find_index_if_impl;
|
||||
template<typename Tuple, typename Predicate, std::size_t I>
|
||||
struct find_index_if_impl<
|
||||
Tuple, Predicate, I,
|
||||
Tuple, Predicate, I, false,
|
||||
void
|
||||
>
|
||||
: public sprout::integral_constant<std::size_t, I>
|
||||
{
|
||||
public:
|
||||
typedef sprout::false_type found;
|
||||
};
|
||||
template<typename Tuple, typename Predicate, std::size_t I>
|
||||
struct find_index_if_impl<
|
||||
Tuple, Predicate, I, true,
|
||||
typename std::enable_if<
|
||||
I == sprout::types::tuple_size<Tuple>::value
|
||||
|| Predicate::template apply<typename sprout::types::tuple_element<I, Tuple>::type>::type::value
|
||||
sprout::types::apply<Predicate, typename sprout::types::tuple_element<I, Tuple>::type>::type::value
|
||||
>::type
|
||||
>
|
||||
: public sprout::integral_constant<std::size_t, I>
|
||||
{};
|
||||
{
|
||||
public:
|
||||
typedef sprout::true_type found;
|
||||
typedef typename sprout::types::tuple_element<I, Tuple>::type element;
|
||||
};
|
||||
template<typename Tuple, typename Predicate, std::size_t I>
|
||||
struct find_index_if_impl<
|
||||
Tuple, Predicate, I,
|
||||
Tuple, Predicate, I, true,
|
||||
typename std::enable_if<
|
||||
I != sprout::types::tuple_size<Tuple>::value
|
||||
&& !Predicate::template apply<typename sprout::types::tuple_element<I, Tuple>::type>::type::value
|
||||
!sprout::types::apply<Predicate, typename sprout::types::tuple_element<I, Tuple>::type>::type::value
|
||||
>::type
|
||||
>
|
||||
: public sprout::types::detail::find_index_if_impl<Tuple, Predicate, I + 1>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/workaround/std/cstddef.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
|
||||
|
@ -29,7 +30,7 @@ namespace sprout {
|
|||
struct fold_impl<Tuple, T, BinaryOp, I, false>
|
||||
: public sprout::types::detail::fold_impl<
|
||||
Tuple,
|
||||
typename BinaryOp::template apply<T, typename sprout::types::tuple_element<I, Tuple>::type>::type,
|
||||
typename sprout::types::apply<BinaryOp, T, typename sprout::types::tuple_element<I, Tuple>::type>::type,
|
||||
BinaryOp,
|
||||
I + 1
|
||||
>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/workaround/std/cstddef.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
#include <sprout/type/functional/less.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
|
@ -41,7 +42,7 @@ namespace sprout {
|
|||
>
|
||||
: public sprout::integral_constant<
|
||||
std::size_t,
|
||||
Compare::template apply<typename sprout::types::tuple_element<First, Tuple>::type, T>::type::value ? Last : First
|
||||
sprout::types::apply<Compare, typename sprout::types::tuple_element<First, Tuple>::type, T>::type::value ? Last : First
|
||||
>
|
||||
{};
|
||||
template<
|
||||
|
@ -50,7 +51,7 @@ namespace sprout {
|
|||
>
|
||||
struct lower_bound_index_impl
|
||||
: public std::conditional<
|
||||
Compare::template apply<typename sprout::types::tuple_element<First + Distance / 2, Tuple>::type, T>::type::value,
|
||||
sprout::types::apply<Compare, typename sprout::types::tuple_element<First + Distance / 2, Tuple>::type, T>::type::value,
|
||||
sprout::types::detail::lower_bound_index_impl<Tuple, T, Compare, First + Distance / 2, Last>,
|
||||
sprout::types::detail::lower_bound_index_impl<Tuple, T, Compare, First, First + Distance / 2>
|
||||
>::type
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/workaround/std/cstddef.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
#include <sprout/type/functional/plus.hpp>
|
||||
|
@ -23,17 +24,13 @@ namespace sprout {
|
|||
struct partial_sum_impl
|
||||
: public sprout::types::detail::partial_sum_impl<
|
||||
Tuple, BinaryOp, I + 1, N - 1,
|
||||
typename BinaryOp::template apply<T, typename sprout::types::tuple_element<I, Tuple>::type>::type,
|
||||
typename sprout::types::apply<BinaryOp, T, typename sprout::types::tuple_element<I, Tuple>::type>::type,
|
||||
Types..., T
|
||||
>
|
||||
{};
|
||||
template<typename Tuple, typename BinaryOp, std::size_t I, typename T, typename... Types>
|
||||
struct partial_sum_impl<Tuple, BinaryOp, I, 0, T, Types...>
|
||||
: public sprout::types::rebind_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
Types..., T
|
||||
>
|
||||
: public sprout::types::apply<sprout::types::rebind_types<Tuple>, Types..., T>
|
||||
{};
|
||||
|
||||
template<typename Tuple, typename BinaryOp, std::size_t N>
|
||||
|
@ -42,9 +39,7 @@ namespace sprout {
|
|||
{};
|
||||
template<typename Tuple, typename BinaryOp>
|
||||
struct partial_sum<Tuple, BinaryOp, 0>
|
||||
: public sprout::types::rebind_types<
|
||||
Tuple
|
||||
>::template apply<>
|
||||
: public sprout::types::apply<sprout::types::rebind_types<Tuple> >
|
||||
{};
|
||||
} // namespace detail
|
||||
//
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple/index_tuple.hpp>
|
||||
#include <sprout/tuple/indexes.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
|
||||
|
@ -21,12 +22,9 @@ namespace sprout {
|
|||
struct transform_impl;
|
||||
template<typename Tuple, typename UnaryOp, sprout::index_t... Indexes>
|
||||
struct transform_impl<Tuple, UnaryOp, sprout::index_tuple<Indexes...> >
|
||||
: public sprout::types::rebind_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
typename UnaryOp::template apply<
|
||||
typename sprout::types::tuple_element<Indexes, Tuple>::type
|
||||
>::type...
|
||||
: public sprout::types::apply<
|
||||
sprout::types::rebind_types<Tuple>,
|
||||
typename sprout::types::apply<UnaryOp, typename sprout::types::tuple_element<Indexes, Tuple>::type>::type...
|
||||
>
|
||||
{};
|
||||
|
||||
|
@ -34,10 +32,10 @@ namespace sprout {
|
|||
struct transform2_impl;
|
||||
template<typename Tuple1, typename Tuple2, typename BinaryOp, sprout::index_t... Indexes>
|
||||
struct transform2_impl<Tuple1, Tuple2, BinaryOp, sprout::index_tuple<Indexes...> >
|
||||
: public sprout::types::rebind_types<
|
||||
Tuple1
|
||||
>::template apply<
|
||||
typename BinaryOp::template apply<
|
||||
: public sprout::types::apply<
|
||||
sprout::types::rebind_types<Tuple1>,
|
||||
typename sprout::types::apply<
|
||||
BinaryOp,
|
||||
typename sprout::types::tuple_element<Indexes, Tuple1>::type,
|
||||
typename sprout::types::tuple_element<Indexes, Tuple2>::type
|
||||
>::type...
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/workaround/std/cstddef.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
#include <sprout/type/functional/less.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
|
@ -41,7 +42,7 @@ namespace sprout {
|
|||
>
|
||||
: public sprout::integral_constant<
|
||||
std::size_t,
|
||||
!Compare::template apply<T, typename sprout::types::tuple_element<First, Tuple>::type>::type::value ? Last : First
|
||||
!sprout::types::apply<Compare, T, typename sprout::types::tuple_element<First, Tuple>::type>::type::value ? Last : First
|
||||
>
|
||||
{};
|
||||
template<
|
||||
|
@ -50,7 +51,7 @@ namespace sprout {
|
|||
>
|
||||
struct upper_bound_index_impl
|
||||
: public std::conditional<
|
||||
!Compare::template apply<T, typename sprout::types::tuple_element<First + Distance / 2, Tuple>::type>::type::value,
|
||||
!sprout::types::apply<Compare, T, typename sprout::types::tuple_element<First + Distance / 2, Tuple>::type>::type::value,
|
||||
sprout::types::detail::upper_bound_index_impl<Tuple, T, Compare, First + Distance / 2, Last>,
|
||||
sprout::types::detail::upper_bound_index_impl<Tuple, T, Compare, First, First + Distance / 2>
|
||||
>::type
|
||||
|
|
64
sprout/type/apply.hpp
Normal file
64
sprout/type/apply.hpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*=============================================================================
|
||||
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_APPLY_HPP
|
||||
#define SPROUT_TYPE_APPLY_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type/quote.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace types {
|
||||
//
|
||||
// apply
|
||||
//
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename F, typename... Types>
|
||||
using apply = typename F::template apply<Types...>;
|
||||
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename F, typename... Types>
|
||||
struct apply
|
||||
: public F::template apply<Types...>
|
||||
{};
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename F, typename... Types>
|
||||
using apply_t = typename sprout::types::apply<F, Types...>::type;
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
||||
#if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
template<typename F, typename... Types>
|
||||
SPROUT_STATIC_CONSTEXPR decltype(sprout::types::apply<F, Types...>::value) apply_v = sprout::types::apply<F, Types...>::value;
|
||||
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
|
||||
//
|
||||
// apply_q
|
||||
//
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<template<typename...> class F, typename... Types>
|
||||
using apply_q = sprout::types::apply<sprout::types::quote<F>, Types...>;
|
||||
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<template<typename...> class F, typename... Types>
|
||||
struct apply_q
|
||||
: public sprout::types::apply<sprout::types::quote<F>, Types...>
|
||||
{};
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<template<typename...> class F, typename... Types>
|
||||
using apply_q_t = typename sprout::types::apply_q<F, Types...>::type;
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
||||
#if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
template<template<typename...> class F, typename... Types>
|
||||
SPROUT_STATIC_CONSTEXPR decltype(sprout::types::apply_q<F, Types...>::value) apply_q_v = sprout::types::apply_q<F, Types...>::value;
|
||||
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
} // namespace types
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_APPLY_HPP
|
|
@ -13,6 +13,7 @@
|
|||
#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/tuple.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
|
||||
|
@ -26,9 +27,8 @@ namespace sprout {
|
|||
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<
|
||||
: public sprout::types::apply<
|
||||
sprout::types::rebind_types<Tuple>,
|
||||
typename sprout::types::tuple_element<Indexes1, Tuple>::type...,
|
||||
typename sprout::types::tuple_element<Indexes2, Tup>::type...
|
||||
>
|
||||
|
@ -243,42 +243,28 @@ namespace sprout {
|
|||
struct joint_types<Tuple const> {
|
||||
public:
|
||||
template<typename Tup>
|
||||
struct apply {
|
||||
public:
|
||||
typedef typename sprout::types::joint_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
Tup
|
||||
>::type const type;
|
||||
};
|
||||
struct apply
|
||||
: public sprout::identity<typename sprout::types::apply<sprout::types::joint_types<Tuple>, Tup>::type const>
|
||||
{};
|
||||
};
|
||||
|
||||
template<typename Tuple>
|
||||
struct joint_types<Tuple volatile> {
|
||||
public:
|
||||
template<typename Tup>
|
||||
struct apply {
|
||||
public:
|
||||
typedef typename sprout::types::joint_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
Tup
|
||||
>::type volatile type;
|
||||
};
|
||||
struct apply
|
||||
: public sprout::identity<typename sprout::types::apply<sprout::types::joint_types<Tuple>, Tup>::type volatile>
|
||||
{};
|
||||
};
|
||||
|
||||
template<typename Tuple>
|
||||
struct joint_types<Tuple const volatile> {
|
||||
public:
|
||||
template<typename Tup>
|
||||
struct apply {
|
||||
public:
|
||||
typedef typename sprout::types::joint_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
Tup
|
||||
>::type const volatile type;
|
||||
};
|
||||
struct apply
|
||||
: public sprout::identity<typename sprout::types::apply<sprout::types::joint_types<Tuple>, Tup>::type const volatile>
|
||||
{};
|
||||
|
||||
};
|
||||
} // namespace types
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#define SPROUT_TYPE_OPERATION_APPEND_FRONT_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
#include <sprout/type/operation/tuple_cat.hpp>
|
||||
|
||||
|
@ -20,7 +21,7 @@ namespace sprout {
|
|||
template<typename Tuple, typename... InputTuples>
|
||||
struct append_front
|
||||
: public sprout::types::tuple_cat<
|
||||
typename sprout::types::rebind_types<Tuple>::template apply<>::type,
|
||||
typename sprout::types::apply<sprout::types::rebind_types<Tuple> >::type,
|
||||
InputTuples..., Tuple
|
||||
>
|
||||
{};
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#define SPROUT_TYPE_OPERATION_ASSIGN_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
#include <sprout/type/operation/tuple_cat.hpp>
|
||||
|
||||
|
@ -20,7 +21,7 @@ namespace sprout {
|
|||
template<typename Tuple, typename InputTuple>
|
||||
struct assign
|
||||
: public sprout::types::tuple_cat<
|
||||
typename sprout::types::rebind_types<Tuple>::template apply<>::type,
|
||||
typename sprout::types::apply<sprout::types::rebind_types<Tuple> >::type,
|
||||
InputTuple
|
||||
>
|
||||
{};
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple/metafunction.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
|
||||
|
@ -25,9 +26,8 @@ namespace sprout {
|
|||
struct apply_impl;
|
||||
template<sprout::index_t... Indexes>
|
||||
struct apply_impl<sprout::index_tuple<Indexes...> >
|
||||
: public sprout::types::rebind_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
: public sprout::types::apply<
|
||||
sprout::types::rebind_types<Tuple>,
|
||||
typename sprout::types::tuple_element<Indexes, Tuple>::type...
|
||||
>
|
||||
{};
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple/metafunction.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
|
||||
|
@ -25,9 +26,8 @@ namespace sprout {
|
|||
struct apply_impl;
|
||||
template<sprout::index_t... Indexes>
|
||||
struct apply_impl<sprout::index_tuple<Indexes...> >
|
||||
: public sprout::types::rebind_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
: public sprout::types::apply<
|
||||
sprout::types::rebind_types<Tuple>,
|
||||
typename sprout::types::tuple_element<Indexes, Tuple>::type...
|
||||
>
|
||||
{};
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#define SPROUT_TYPE_OPERATION_PUSH_FRONT_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
#include <sprout/type/type_tuple.hpp>
|
||||
#include <sprout/type/operation/tuple_cat.hpp>
|
||||
|
@ -21,7 +22,7 @@ namespace sprout {
|
|||
template<typename Tuple, typename... Ts>
|
||||
struct push_front
|
||||
: public sprout::types::tuple_cat<
|
||||
typename sprout::types::rebind_types<Tuple>::template apply<>::type,
|
||||
typename sprout::types::apply<sprout::types::rebind_types<Tuple> >::type,
|
||||
sprout::types::type_tuple<Ts...>, Tuple
|
||||
>
|
||||
{};
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#define SPROUT_TYPE_OPERATION_REBIND_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
#include <sprout/type/rebind_types.hpp>
|
||||
|
||||
namespace sprout {
|
||||
|
@ -18,7 +19,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename Tuple, typename... Ts>
|
||||
struct rebind
|
||||
: public sprout::types::rebind_types<Tuple>::template apply<Ts...>
|
||||
: public sprout::types::apply<sprout::types::rebind_types<Tuple>, Ts...>
|
||||
{};
|
||||
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/index_tuple.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
#include <sprout/type/joint_types.hpp>
|
||||
#include <sprout/type/type_tuple.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
|
@ -28,13 +29,14 @@ namespace sprout {
|
|||
struct tuple_cat_impl;
|
||||
template<typename Tuples, sprout::index_t... LIndexes, sprout::index_t... RIndexes>
|
||||
struct tuple_cat_impl<Tuples, sprout::index_tuple<LIndexes...>, sprout::index_tuple<RIndexes...> >
|
||||
: public sprout::types::joint_types<
|
||||
typename sprout::types::detail::tuple_cat_impl<
|
||||
sprout::types::type_tuple<typename sprout::types::tuple_element<LIndexes, Tuples>::type...>,
|
||||
typename sprout::index_range<0, sizeof...(LIndexes) / 2>::type,
|
||||
typename sprout::index_range<sizeof...(LIndexes) / 2, sizeof...(LIndexes)>::type
|
||||
>::type
|
||||
>::template apply<
|
||||
: public sprout::types::apply<
|
||||
sprout::types::joint_types<
|
||||
typename sprout::types::detail::tuple_cat_impl<
|
||||
sprout::types::type_tuple<typename sprout::types::tuple_element<LIndexes, Tuples>::type...>,
|
||||
typename sprout::index_range<0, sizeof...(LIndexes) / 2>::type,
|
||||
typename sprout::index_range<sizeof...(LIndexes) / 2, sizeof...(LIndexes)>::type
|
||||
>::type
|
||||
>,
|
||||
typename sprout::types::detail::tuple_cat_impl<
|
||||
sprout::types::type_tuple<typename sprout::types::tuple_element<RIndexes, Tuples>::type...>,
|
||||
typename sprout::index_range<0, sizeof...(RIndexes) / 2>::type,
|
||||
|
|
34
sprout/type/quote.hpp
Normal file
34
sprout/type/quote.hpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*=============================================================================
|
||||
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_QUOTE_HPP
|
||||
#define SPROUT_TYPE_QUOTE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace types {
|
||||
//
|
||||
// quote
|
||||
//
|
||||
template<template<typename...> class F>
|
||||
struct quote {
|
||||
public:
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename... Types>
|
||||
using apply = F<Types...>;
|
||||
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename... Types>
|
||||
struct apply
|
||||
: public F<Types...>
|
||||
{};
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
};
|
||||
} // namespace types
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_QUOTE_HPP
|
|
@ -11,6 +11,7 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/index_tuple/index_t.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace types {
|
||||
|
@ -75,42 +76,27 @@ namespace sprout {
|
|||
struct rebind_types<Tuple const> {
|
||||
public:
|
||||
template<typename... Types>
|
||||
struct apply {
|
||||
public:
|
||||
typedef typename sprout::types::rebind_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
Types...
|
||||
>::type const type;
|
||||
};
|
||||
struct apply
|
||||
: public sprout::identity<typename sprout::types::apply<sprout::types::rebind_types<Tuple>, Types...>::type const>
|
||||
{};
|
||||
};
|
||||
|
||||
template<typename Tuple>
|
||||
struct rebind_types<Tuple volatile> {
|
||||
public:
|
||||
template<typename... Types>
|
||||
struct apply {
|
||||
public:
|
||||
typedef typename sprout::types::rebind_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
Types...
|
||||
>::type volatile type;
|
||||
};
|
||||
struct apply
|
||||
: public sprout::identity<typename sprout::types::apply<sprout::types::rebind_types<Tuple>, Types...>::type volatile>
|
||||
{};
|
||||
};
|
||||
|
||||
template<typename Tuple>
|
||||
struct rebind_types<Tuple const volatile> {
|
||||
public:
|
||||
template<typename... Types>
|
||||
struct apply {
|
||||
public:
|
||||
typedef typename sprout::types::rebind_types<
|
||||
Tuple
|
||||
>::template apply<
|
||||
Types...
|
||||
>::type const volatile type;
|
||||
};
|
||||
struct apply
|
||||
: public sprout::identity<typename sprout::types::apply<sprout::types::rebind_types<Tuple>, Types...>::type const volatile>
|
||||
{};
|
||||
};
|
||||
} // namespace types
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type/apply.hpp>
|
||||
#include <sprout/type/tuple.hpp>
|
||||
|
||||
namespace sprout {
|
||||
|
@ -25,7 +26,7 @@ namespace sprout {
|
|||
struct find_if_impl_1<
|
||||
First, Last, Predicate,
|
||||
typename std::enable_if<
|
||||
Predicate::template apply<typename sprout::types::deref<First>::type>::type::value
|
||||
sprout::types::apply<Predicate, typename sprout::types::deref<First>::type>::type::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
|
@ -35,7 +36,7 @@ namespace sprout {
|
|||
struct find_if_impl_1<
|
||||
First, Last, Predicate,
|
||||
typename std::enable_if<
|
||||
!Predicate::template apply<typename sprout::types::deref<First>::type>::type::value
|
||||
!sprout::types::apply<Predicate, typename sprout::types::deref<First>::type>::type::value
|
||||
>::type
|
||||
>
|
||||
: public sprout::types::seq::detail::find_if_impl<
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <sprout/type_traits/common_decay.hpp>
|
||||
#include <sprout/type/type_tuple.hpp>
|
||||
#include <sprout/type/algorithm/find_index.hpp>
|
||||
#include <sprout/type/algorithm/contains.hpp>
|
||||
#include <sprout/functional/type_traits/has_type.hpp>
|
||||
#include <sprout/functional/type_traits/weak_result_type.hpp>
|
||||
#include <sprout/variant/variant_fwd.hpp>
|
||||
|
@ -312,14 +313,14 @@ namespace sprout {
|
|||
}
|
||||
template<typename U>
|
||||
SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::types::find_index<tuple_type, U>::value != sizeof...(Types),
|
||||
sprout::types::contains<tuple_type, U>::value,
|
||||
U const&
|
||||
>::type get() const {
|
||||
return get_at<sprout::types::find_index<tuple_type, U>::value>();
|
||||
}
|
||||
template<typename U>
|
||||
SPROUT_CXX14_CONSTEXPR typename std::enable_if<
|
||||
sprout::types::find_index<tuple_type, U>::value != sizeof...(Types),
|
||||
sprout::types::contains<tuple_type, U>::value,
|
||||
U&
|
||||
>::type get() {
|
||||
return get_at<sprout::types::find_index<tuple_type, U>::value>();
|
||||
|
|
Loading…
Reference in a new issue