diff --git a/sprout/functional/bind/bind.hpp b/sprout/functional/bind/bind.hpp index 84c7dbf4..6e4436b2 100644 --- a/sprout/functional/bind/bind.hpp +++ b/sprout/functional/bind/bind.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -188,21 +189,14 @@ namespace sprout { return sprout::tuples::get(const_cast const&>(tuple)); } - template - struct is_variadic_placeholder - : public std::integral_constant< - bool, - (sprout::is_placeholder::value - <= sprout::is_placeholder::value - ) - > - {}; - struct is_variadic_placeholder_pred { public: template struct apply - : public sprout::detail::is_variadic_placeholder + : public std::integral_constant< + bool, + (sprout::is_variadic_placeholder::value > 0) + > {}; }; template @@ -213,21 +207,9 @@ namespace sprout { > {}; - template - struct tail_place - : public std::integral_constant - {}; template - struct tail_place< - T, - typename std::enable_if::value>::type - > - : public std::integral_constant< - int, - (sprout::is_placeholder::value - - sprout::is_placeholder::value - ) - > + struct tail_place + : public std::integral_constant::value - 1> {}; template @@ -237,7 +219,7 @@ namespace sprout { template struct bound_size< T, ArgSize, - typename std::enable_if::value>::type + typename std::enable_if<(sprout::is_variadic_placeholder::value > 0)>::type > : public std::integral_constant< std::size_t, @@ -292,39 +274,11 @@ namespace sprout { : public sprout::make_index_tuple::value> {}; - struct meta_less_ { - public: - template - struct apply - : public std::integral_constant - {}; - }; - - template - struct lower_bound_index_impl - : public std::integral_constant - {}; - template - struct lower_bound_index_impl< - I, Tuple, T, Compare, - typename std::enable_if<(I < sprout::tuples::tuple_size::value)>::type - > - : public std::conditional< - Compare::template apply::type, T>::type::value, - sprout::detail::lower_bound_index_impl, - std::integral_constant - >::type - {}; - template - struct lower_bound_index - : public sprout::detail::lower_bound_index_impl<0, Tuple, T, Compare> - {}; - template struct bound_position : public std::integral_constant< sprout::index_t, - (sprout::detail::lower_bound_index< + (sprout::types::lower_bound_index< typename sprout::detail::bounds_partial_size::type, std::integral_constant >::type::value - 1 @@ -334,11 +288,15 @@ namespace sprout { template struct is_variadic_part - : public sprout::detail::is_variadic_placeholder< - typename sprout::tuples::tuple_element< - sprout::detail::bound_position::value, - Bounds - >::type + : public std::integral_constant< + bool, + (sprout::is_variadic_placeholder< + typename sprout::tuples::tuple_element< + sprout::detail::bound_position::value, + Bounds + >::type + >::value > 0 + ) > {}; @@ -730,7 +688,7 @@ namespace sprout { template struct complete_placeholder< Index, BoundArg, - typename std::enable_if::value == sprout::is_placeholder::value)>::type + typename std::enable_if::value>::type > { public: typedef BoundArg type; @@ -738,7 +696,7 @@ namespace sprout { template struct complete_placeholder< Index, BoundArg, - typename std::enable_if<(sprout::is_placeholder::value == sprout::is_placeholder::value)>::type + typename std::enable_if::value>::type > { public: typedef sprout::placeholder type; diff --git a/sprout/functional/bind/placeholder.hpp b/sprout/functional/bind/placeholder.hpp index a5a5be77..2fd07c6a 100644 --- a/sprout/functional/bind/placeholder.hpp +++ b/sprout/functional/bind/placeholder.hpp @@ -9,19 +9,22 @@ namespace sprout { // placeholder // template - struct placeholder -// : public std::integral_constant - {}; - template<> - struct placeholder<-1> -// : public std::integral_constant - { + struct placeholder {}; + // + // positional_placeholder + // + struct positional_placeholder { public: - template - SPROUT_CONSTEXPR operator sprout::placeholder() const { - return sprout::placeholder(); + template + SPROUT_CONSTEXPR operator sprout::placeholder() const { + return sprout::placeholder(); } }; + // + // variadic_placeholder + // + template + struct variadic_placeholder {}; namespace placeholders { namespace { @@ -56,39 +59,39 @@ namespace sprout { SPROUT_STATIC_CONSTEXPR sprout::placeholder<29> _29 = {}; SPROUT_STATIC_CONSTEXPR sprout::placeholder<30> _30 = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-1> _ = {}; + SPROUT_STATIC_CONSTEXPR sprout::positional_placeholder _ = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256> _va = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 1> _1tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 2> _2tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 3> _3tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 4> _4tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 5> _5tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 6> _6tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 7> _7tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 8> _8tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 9> _9tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 10> _10tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 11> _11tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 12> _12tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 13> _13tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 14> _14tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 15> _15tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 16> _16tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 17> _17tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 18> _18tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 19> _19tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 20> _20tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 21> _21tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 22> _22tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 23> _23tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 24> _24tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 25> _25tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 26> _26tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 27> _27tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 28> _28tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 29> _29tail = {}; - SPROUT_STATIC_CONSTEXPR sprout::placeholder<-256 - 30> _30tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<0> _va = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<1> _1tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<2> _2tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<3> _3tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<4> _4tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<5> _5tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<6> _6tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<7> _7tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<8> _8tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<9> _9tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<10> _10tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<11> _11tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<12> _12tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<13> _13tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<14> _14tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<15> _15tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<16> _16tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<17> _17tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<18> _18tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<19> _19tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<20> _20tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<21> _21tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<22> _22tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<23> _23tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<24> _24tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<25> _25tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<26> _26tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<27> _27tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<28> _28tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<29> _29tail = {}; + SPROUT_STATIC_CONSTEXPR sprout::variadic_placeholder<30> _30tail = {}; } // anonymous-namespace } // namespace placeholders using sprout::placeholders::_1; @@ -163,10 +166,6 @@ namespace sprout { struct is_placeholder : public std::integral_constant {}; - template - struct is_placeholder > - : public std::integral_constant - {}; template struct is_placeholder : public sprout::is_placeholder @@ -179,6 +178,58 @@ namespace sprout { struct is_placeholder : public sprout::is_placeholder {}; + template + struct is_placeholder > + : public std::integral_constant + {}; + + // + // is_positional_placeholder + // + template + struct is_positional_placeholder + : public std::integral_constant + {}; + template + struct is_positional_placeholder + : public sprout::is_positional_placeholder + {}; + template + struct is_positional_placeholder + : public sprout::is_positional_placeholder + {}; + template + struct is_positional_placeholder + : public sprout::is_positional_placeholder + {}; + template<> + struct is_positional_placeholder + : public std::integral_constant + {}; + + // + // is_variadic_placeholder + // + template + struct is_variadic_placeholder + : public std::integral_constant + {}; + template + struct is_variadic_placeholder + : public sprout::is_variadic_placeholder + {}; + template + struct is_variadic_placeholder + : public sprout::is_variadic_placeholder + {}; + template + struct is_variadic_placeholder + : public sprout::is_variadic_placeholder + {}; + template + struct is_variadic_placeholder > + : public std::integral_constant + {}; } // namespace sprout #endif // #ifndef SPROUT_FUNCTIONAL_BIND_PLACEHOLDER_HPP diff --git a/sprout/type.hpp b/sprout/type.hpp index ed428b39..6421f441 100644 --- a/sprout/type.hpp +++ b/sprout/type.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/sprout/type/algorithm.hpp b/sprout/type/algorithm.hpp index 16097cdd..32f0390d 100644 --- a/sprout/type/algorithm.hpp +++ b/sprout/type/algorithm.hpp @@ -4,5 +4,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_TYPE_ALGORITHM_HPP diff --git a/sprout/type/algorithm/lower_bound_index.hpp b/sprout/type/algorithm/lower_bound_index.hpp new file mode 100644 index 00000000..79a0e341 --- /dev/null +++ b/sprout/type/algorithm/lower_bound_index.hpp @@ -0,0 +1,39 @@ +#ifndef SPROUT_TYPE_ALGORITHM_LOWER_BOUND_INDEX_HPP +#define SPROUT_TYPE_ALGORITHM_LOWER_BOUND_INDEX_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace types { + namespace detail { + template + struct lower_bound_index_impl + : public std::integral_constant + {}; + template + struct lower_bound_index_impl< + I, Tuple, T, Compare, + typename std::enable_if<(I < sprout::tuples::tuple_size::value)>::type + > + : public std::conditional< + Compare::template apply::type, T>::type::value, + sprout::types::detail::lower_bound_index_impl, + std::integral_constant + >::type + {}; + } // namespace detail + // + // lower_bound_index + // + template + struct lower_bound_index + : public sprout::types::detail::lower_bound_index_impl<0, Tuple, T, Compare> + {}; + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_ALGORITHM_LOWER_BOUND_INDEX_HPP diff --git a/sprout/type/functional.hpp b/sprout/type/functional.hpp new file mode 100644 index 00000000..3c0f3a4c --- /dev/null +++ b/sprout/type/functional.hpp @@ -0,0 +1,7 @@ +#ifndef SPROUT_TYPE_FUNCTIONAL_HPP +#define SPROUT_TYPE_FUNCTIONAL_HPP + +#include +#include + +#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_HPP diff --git a/sprout/type/functional/less.hpp b/sprout/type/functional/less.hpp new file mode 100644 index 00000000..6151c296 --- /dev/null +++ b/sprout/type/functional/less.hpp @@ -0,0 +1,30 @@ +#ifndef SPROUT_TYPE_FUNCTIONAL_LESS_HPP +#define SPROUT_TYPE_FUNCTIONAL_LESS_HPP + +#include +#include + +namespace sprout { + namespace types { + // + // less + // + template + struct less + : public std::integral_constant + {}; + + // + // less_ + // + struct less_ { + public: + template + struct apply + : public sprout::types::less + {}; + }; + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_FUNCTIONAL_LESS_HPP