diff --git a/sprout/array.hpp b/sprout/array.hpp index 9c95fabe..77a13bc4 100644 --- a/sprout/array.hpp +++ b/sprout/array.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT #if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION # include @@ -286,6 +287,31 @@ namespace sprout { struct is_array > : public std::true_type {}; + + namespace tuples { + // + // get + // + template + inline SPROUT_CONSTEXPR T& + get(sprout::array& t) SPROUT_NOEXCEPT { + static_assert(I < N, "get: index out of range"); + return t[I]; + } + template + inline SPROUT_CONSTEXPR T const& + get(sprout::array const& t) SPROUT_NOEXCEPT { + static_assert(I < N, "get: index out of range"); + return t[I]; + } + template + inline SPROUT_CONSTEXPR T&& + get(sprout::array&& t) SPROUT_NOEXCEPT { + return sprout::move(sprout::tuples::get(t)); + } + } // namespace tuples + + using sprout::tuples::get; } // namespace sprout namespace std { @@ -308,6 +334,4 @@ namespace std { }; } // namespace std -#include - #endif // #ifndef SPROUT_ARRAY_HPP diff --git a/sprout/functional.hpp b/sprout/functional.hpp index e0f8b237..4b3cb19a 100644 --- a/sprout/functional.hpp +++ b/sprout/functional.hpp @@ -9,5 +9,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_FUNCTIONAL_HPP diff --git a/sprout/functional/hash/pit.hpp b/sprout/functional/hash/pit.hpp new file mode 100644 index 00000000..b37e6e49 --- /dev/null +++ b/sprout/functional/hash/pit.hpp @@ -0,0 +1,15 @@ +#ifndef SPROUT_FUNCTIONAL_HASH_PIT_HPP +#define SPROUT_FUNCTIONAL_HASH_PIT_HPP + +#include +#include +#include + +namespace sprout { + template + SPROUT_CONSTEXPR std::size_t hash_value(sprout::pit const& v) { + return sprout::to_hash(v.elem); + } +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_HASH_PIT_HPP diff --git a/sprout/functional/polymorphic.hpp b/sprout/functional/polymorphic.hpp new file mode 100644 index 00000000..2e27561f --- /dev/null +++ b/sprout/functional/polymorphic.hpp @@ -0,0 +1,7 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_HPP + +#include +#include + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_HPP diff --git a/sprout/functional/polymorphic/address_of.hpp b/sprout/functional/polymorphic/address_of.hpp new file mode 100644 index 00000000..9eec3b96 --- /dev/null +++ b/sprout/functional/polymorphic/address_of.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_ADDRESS_OF_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_ADDRESS_OF_HPP + +#include +#include +#include + +namespace sprout { + // + // address_of_t + // address_of_ + // + struct address_of_t { + public: + template + SPROUT_CONSTEXPR decltype(&std::declval()) + operator()(T&& x) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(&std::declval())) + { + return &sprout::forward(x); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::address_of_t address_of_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_ADDRESS_OF_HPP diff --git a/sprout/functional/polymorphic/arithmetic.hpp b/sprout/functional/polymorphic/arithmetic.hpp new file mode 100644 index 00000000..94e18608 --- /dev/null +++ b/sprout/functional/polymorphic/arithmetic.hpp @@ -0,0 +1,13 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_ARITHMETIC_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_ARITHMETIC_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_ARITHMETIC_HPP diff --git a/sprout/functional/polymorphic/assign.hpp b/sprout/functional/polymorphic/assign.hpp new file mode 100644 index 00000000..588b3748 --- /dev/null +++ b/sprout/functional/polymorphic/assign.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_ASSIGN_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_ASSIGN_HPP + +#include +#include +#include + +namespace sprout { + // + // assign_t + // assign_ + // + struct assign_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() = std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() = std::declval())) + { + return sprout::forward(x) = sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::assign_t assign_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_ASSIGN_HPP diff --git a/sprout/functional/polymorphic/assignment.hpp b/sprout/functional/polymorphic/assignment.hpp new file mode 100644 index 00000000..17aa02c6 --- /dev/null +++ b/sprout/functional/polymorphic/assignment.hpp @@ -0,0 +1,16 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_ASSIGNMENT_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_ASSIGNMENT_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_ASSIGNMENT_HPP diff --git a/sprout/functional/polymorphic/bind1st.hpp b/sprout/functional/polymorphic/bind1st.hpp new file mode 100644 index 00000000..ae97fffe --- /dev/null +++ b/sprout/functional/polymorphic/bind1st.hpp @@ -0,0 +1,39 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIND1ST_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIND1ST_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // binder1st_ + // bind1st_ + // + template + class binder1st_ { + protected: + Fn op; + T value; + public: + SPROUT_CONSTEXPR binder1st_(Fn&& x, T&& y) + : op(sprout::forward(x)), value(sprout::forward(y)) + {} + template + SPROUT_CONSTEXPR decltype(op(value, std::declval())) + operator()(Arg&& x) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(op(value, std::declval()))) + { + return op(value, sprout::forward(x)); + } + }; + template + SPROUT_CONSTEXPR sprout::binder1st_::type, typename std::decay::type> + bind1st_(Fn&& fn, T&& x) { + typedef sprout::binder1st_::type, typename std::decay::type> type; + return type(sprout::forward(fn), sprout::forward(x)); + } +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIND1ST_HPP diff --git a/sprout/functional/polymorphic/bind2nd.hpp b/sprout/functional/polymorphic/bind2nd.hpp new file mode 100644 index 00000000..d08ac009 --- /dev/null +++ b/sprout/functional/polymorphic/bind2nd.hpp @@ -0,0 +1,39 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIND2ND_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIND2ND_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // binder2nd_ + // bind2nd_ + // + template + class binder2nd_ { + protected: + Fn op; + T value; + public: + SPROUT_CONSTEXPR binder2nd_(Fn&& x, T&& y) + : op(sprout::forward(x)), value(sprout::forward(y)) + {} + template + SPROUT_CONSTEXPR decltype(op(std::declval(), value)) + operator()(Arg&& x) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(op(std::declval(), value))) + { + return op(sprout::forward(x), value); + } + }; + template + SPROUT_CONSTEXPR sprout::binder2nd_::type, typename std::decay::type> + bind2nd_(Fn&& fn, T&& x) { + typedef sprout::binder2nd_::type, typename std::decay::type> type; + return type(sprout::forward(fn), sprout::forward(x)); + } +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIND2ND_HPP diff --git a/sprout/functional/polymorphic/binder.hpp b/sprout/functional/polymorphic/binder.hpp new file mode 100644 index 00000000..7c97128c --- /dev/null +++ b/sprout/functional/polymorphic/binder.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BINDER_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_BINDER_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BINDER_HPP diff --git a/sprout/functional/polymorphic/bit_and.hpp b/sprout/functional/polymorphic/bit_and.hpp new file mode 100644 index 00000000..e6b5382b --- /dev/null +++ b/sprout/functional/polymorphic/bit_and.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_AND_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_AND_HPP + +#include +#include +#include + +namespace sprout { + // + // bit_and_t + // bit_and_ + // + struct bit_and_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() & std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() & std::declval())) + { + return sprout::forward(x) & sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::bit_and_t bit_and_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_AND_HPP diff --git a/sprout/functional/polymorphic/bit_and_assign.hpp b/sprout/functional/polymorphic/bit_and_assign.hpp new file mode 100644 index 00000000..8d77af5a --- /dev/null +++ b/sprout/functional/polymorphic/bit_and_assign.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_AND_ASSIGN_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_AND_ASSIGN_HPP + +#include +#include +#include + +namespace sprout { + // + // bit_and_assign_t + // bit_and_assign_ + // + struct bit_and_assign_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() &= std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() &= std::declval())) + { + return sprout::forward(x) &= sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::bit_and_assign_t bit_and_assign_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_AND_ASSIGN_HPP diff --git a/sprout/functional/polymorphic/bit_not.hpp b/sprout/functional/polymorphic/bit_not.hpp new file mode 100644 index 00000000..bb0e6c43 --- /dev/null +++ b/sprout/functional/polymorphic/bit_not.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_NOT_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_NOT_HPP + +#include +#include +#include + +namespace sprout { + // + // bit_not_t + // bit_not_ + // + struct bit_not_t { + public: + template + SPROUT_CONSTEXPR decltype(~std::declval()) + operator()(T&& x) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(~std::declval())) + { + return ~sprout::forward(x); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::bit_not_t bit_not_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_NOT_HPP diff --git a/sprout/functional/polymorphic/bit_or.hpp b/sprout/functional/polymorphic/bit_or.hpp new file mode 100644 index 00000000..53def873 --- /dev/null +++ b/sprout/functional/polymorphic/bit_or.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_OR_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_OR_HPP + +#include +#include +#include + +namespace sprout { + // + // bit_or_t + // bit_or_ + // + struct bit_or_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() | std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() | std::declval())) + { + return sprout::forward(x) | sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::bit_or_t bit_or_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_OR_HPP diff --git a/sprout/functional/polymorphic/bit_or_assign.hpp b/sprout/functional/polymorphic/bit_or_assign.hpp new file mode 100644 index 00000000..a53731c6 --- /dev/null +++ b/sprout/functional/polymorphic/bit_or_assign.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_OR_ASSIGN_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_OR_ASSIGN_HPP + +#include +#include +#include + +namespace sprout { + // + // bit_or_assign_t + // bit_or_assign_ + // + struct bit_or_assign_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() |= std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() |= std::declval())) + { + return sprout::forward(x) |= sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::bit_or_assign_t bit_or_assign_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_OR_ASSIGN_HPP diff --git a/sprout/functional/polymorphic/bit_xor.hpp b/sprout/functional/polymorphic/bit_xor.hpp new file mode 100644 index 00000000..c16507d9 --- /dev/null +++ b/sprout/functional/polymorphic/bit_xor.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_XOR_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_XOR_HPP + +#include +#include +#include + +namespace sprout { + // + // bit_xor_t + // bit_xor_ + // + struct bit_xor_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() ^ std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() ^ std::declval())) + { + return sprout::forward(x) ^ sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::bit_xor_t bit_xor_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_XOR_HPP diff --git a/sprout/functional/polymorphic/bit_xor_assign.hpp b/sprout/functional/polymorphic/bit_xor_assign.hpp new file mode 100644 index 00000000..43779b4e --- /dev/null +++ b/sprout/functional/polymorphic/bit_xor_assign.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_XOR_ASSIGN_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_XOR_ASSIGN_HPP + +#include +#include +#include + +namespace sprout { + // + // bit_xor_assign_t + // bit_xor_assign_ + // + struct bit_xor_assign_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() ^= std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() ^= std::declval())) + { + return sprout::forward(x) ^= sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::bit_xor_assign_t bit_xor_assign_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_XOR_ASSIGN_HPP diff --git a/sprout/functional/polymorphic/bitwise.hpp b/sprout/functional/polymorphic/bitwise.hpp new file mode 100644 index 00000000..aa7453cf --- /dev/null +++ b/sprout/functional/polymorphic/bitwise.hpp @@ -0,0 +1,12 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BITWISE_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_BITWISE_HPP + +#include +#include +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BITWISE_HPP diff --git a/sprout/functional/polymorphic/call_fun.hpp b/sprout/functional/polymorphic/call_fun.hpp new file mode 100644 index 00000000..7ecdee34 --- /dev/null +++ b/sprout/functional/polymorphic/call_fun.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_CALL_FUN_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_CALL_FUN_HPP + +#include +#include +#include + +namespace sprout { + // + // call_fun_t + // call_fun_ + // + struct call_fun_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval()(std::declval()...)) + operator()(F&& f, As&&... as) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval()(std::declval()...))) + { + return sprout::forward(f)(sprout::forward(as)...); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::call_fun_t call_fun_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_CALL_FUN_HPP diff --git a/sprout/functional/polymorphic/comma.hpp b/sprout/functional/polymorphic/comma.hpp new file mode 100644 index 00000000..0cb32a77 --- /dev/null +++ b/sprout/functional/polymorphic/comma.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_COMMA_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_COMMA_HPP + +#include +#include +#include + +namespace sprout { + // + // comma_t + // comma_ + // + struct comma_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval(), std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR((std::declval(), std::declval()))) + { + return sprout::forward(x), sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::comma_t comma_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_COMMA_HPP diff --git a/sprout/functional/polymorphic/comparison.hpp b/sprout/functional/polymorphic/comparison.hpp new file mode 100644 index 00000000..7e652f3d --- /dev/null +++ b/sprout/functional/polymorphic/comparison.hpp @@ -0,0 +1,12 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_COMPARISON_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_COMPARISON_HPP + +#include +#include +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_COMPARISON_HPP diff --git a/sprout/functional/polymorphic/cond.hpp b/sprout/functional/polymorphic/cond.hpp new file mode 100644 index 00000000..b21b26a0 --- /dev/null +++ b/sprout/functional/polymorphic/cond.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_COND_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_COND_HPP + +#include +#include +#include + +namespace sprout { + // + // cond_t + // cond_ + // + struct cond_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() ? std::declval() : std::declval()) + operator()(T&& x, U&& y, V&& z) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() ? std::declval() : std::declval())) + { + return sprout::forward(x) ? sprout::forward(y) : sprout::forward(z); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::cond_t cond_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_COND_HPP diff --git a/sprout/functional/polymorphic/dereference.hpp b/sprout/functional/polymorphic/dereference.hpp new file mode 100644 index 00000000..53d09d47 --- /dev/null +++ b/sprout/functional/polymorphic/dereference.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_DEREFERENCE_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_DEREFERENCE_HPP + +#include +#include +#include + +namespace sprout { + // + // dereference_t + // dereference_ + // + struct dereference_t { + public: + template + SPROUT_CONSTEXPR decltype(*std::declval()) + operator()(T&& x) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(*std::declval())) + { + return *sprout::forward(x); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::dereference_t dereference_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_DEREFERENCE_HPP diff --git a/sprout/functional/polymorphic/divides.hpp b/sprout/functional/polymorphic/divides.hpp new file mode 100644 index 00000000..d84cd4bb --- /dev/null +++ b/sprout/functional/polymorphic/divides.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_DEVIDES_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_DEVIDES_HPP + +#include +#include +#include + +namespace sprout { + // + // divides_t + // divides_ + // + struct divides_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() / std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() / std::declval())) + { + return sprout::forward(x) / sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::divides_t divides_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_DEVIDES_HPP diff --git a/sprout/functional/polymorphic/divides_assign.hpp b/sprout/functional/polymorphic/divides_assign.hpp new file mode 100644 index 00000000..f5b66a62 --- /dev/null +++ b/sprout/functional/polymorphic/divides_assign.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_DEVIDES_ASSIGN_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_DEVIDES_ASSIGN_HPP + +#include +#include +#include + +namespace sprout { + // + // divides_assign_t + // divides_assign_ + // + struct divides_assign_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() /= std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() /= std::declval())) + { + return sprout::forward(x) /= sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::divides_assign_t divides_assign_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_DEVIDES_ASSIGN_HPP diff --git a/sprout/functional/polymorphic/equal_to.hpp b/sprout/functional/polymorphic/equal_to.hpp new file mode 100644 index 00000000..1f3fcae8 --- /dev/null +++ b/sprout/functional/polymorphic/equal_to.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_EQUAL_TO_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_EQUAL_TO_HPP + +#include +#include +#include + +namespace sprout { + // + // equal_to_t + // equal_to_ + // + struct equal_to_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() == std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() == std::declval())) + { + return sprout::forward(x) == sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::equal_to_t equal_to_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_EQUAL_TO_HPP diff --git a/sprout/functional/polymorphic/functor.hpp b/sprout/functional/polymorphic/functor.hpp new file mode 100644 index 00000000..17871cb4 --- /dev/null +++ b/sprout/functional/polymorphic/functor.hpp @@ -0,0 +1,15 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_FUNCTOR_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_FUNCTOR_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_FUNCTOR_HPP diff --git a/sprout/functional/polymorphic/greater.hpp b/sprout/functional/polymorphic/greater.hpp new file mode 100644 index 00000000..b2c886c9 --- /dev/null +++ b/sprout/functional/polymorphic/greater.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_GREATER_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_GREATER_HPP + +#include +#include +#include + +namespace sprout { + // + // greater_t + // greater_ + // + struct greater_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() > std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() > std::declval())) + { + return sprout::forward(x) > sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::greater_t greater_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_GREATER_HPP diff --git a/sprout/functional/polymorphic/greater_equal.hpp b/sprout/functional/polymorphic/greater_equal.hpp new file mode 100644 index 00000000..f70d78cd --- /dev/null +++ b/sprout/functional/polymorphic/greater_equal.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_GREATER_EQUAL_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_GREATER_EQUAL_HPP + +#include +#include +#include + +namespace sprout { + // + // greater_equal_t + // greater_equal_ + // + struct greater_equal_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() >= std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() >= std::declval())) + { + return sprout::forward(x) >= sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::greater_equal_t greater_equal_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_GREATER_EQUAL_HPP diff --git a/sprout/functional/polymorphic/inc_dec.hpp b/sprout/functional/polymorphic/inc_dec.hpp new file mode 100644 index 00000000..5c3c7269 --- /dev/null +++ b/sprout/functional/polymorphic/inc_dec.hpp @@ -0,0 +1,10 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_INC_DEC_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_INC_DEC_HPP + +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_INC_DEC_HPP diff --git a/sprout/functional/polymorphic/less.hpp b/sprout/functional/polymorphic/less.hpp new file mode 100644 index 00000000..c3250bcc --- /dev/null +++ b/sprout/functional/polymorphic/less.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LESS_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_LESS_HPP + +#include +#include +#include + +namespace sprout { + // + // less_t + // less_ + // + struct less_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() < std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() < std::declval())) + { + return sprout::forward(x) < sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::less_t less_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LESS_HPP diff --git a/sprout/functional/polymorphic/less_equal.hpp b/sprout/functional/polymorphic/less_equal.hpp new file mode 100644 index 00000000..d07e6d0c --- /dev/null +++ b/sprout/functional/polymorphic/less_equal.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LESS_EQUAL_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_LESS_EQUAL_HPP + +#include +#include +#include + +namespace sprout { + // + // less_equal_t + // less_equal_ + // + struct less_equal_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() <= std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() <= std::declval())) + { + return sprout::forward(x) <= sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::less_equal_t less_equal_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LESS_EQUAL_HPP diff --git a/sprout/functional/polymorphic/logical.hpp b/sprout/functional/polymorphic/logical.hpp new file mode 100644 index 00000000..46496ec9 --- /dev/null +++ b/sprout/functional/polymorphic/logical.hpp @@ -0,0 +1,9 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_HPP + +#include +#include +#include +#include + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_HPP diff --git a/sprout/functional/polymorphic/logical_and.hpp b/sprout/functional/polymorphic/logical_and.hpp new file mode 100644 index 00000000..29d4d870 --- /dev/null +++ b/sprout/functional/polymorphic/logical_and.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_AND_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_AND_HPP + +#include +#include +#include + +namespace sprout { + // + // logical_and_t + // logical_and_ + // + struct logical_and_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() && std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() && std::declval())) + { + return sprout::forward(x) && sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::logical_and_t logical_and_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_AND_HPP diff --git a/sprout/functional/polymorphic/logical_not.hpp b/sprout/functional/polymorphic/logical_not.hpp new file mode 100644 index 00000000..14695e3b --- /dev/null +++ b/sprout/functional/polymorphic/logical_not.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_NOT_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_NOT_HPP + +#include +#include +#include + +namespace sprout { + // + // logical_not_t + // logical_not_ + // + struct logical_not_t { + public: + template + SPROUT_CONSTEXPR decltype(!std::declval()) + operator()(T&& x) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(!std::declval())) + { + return !sprout::forward(x); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::logical_not_t logical_not_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_NOT_HPP diff --git a/sprout/functional/polymorphic/logical_or.hpp b/sprout/functional/polymorphic/logical_or.hpp new file mode 100644 index 00000000..5e7c7cd0 --- /dev/null +++ b/sprout/functional/polymorphic/logical_or.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_OR_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_OR_HPP + +#include +#include +#include + +namespace sprout { + // + // logical_or_t + // logical_or_ + // + struct logical_or_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() || std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() || std::declval())) + { + return sprout::forward(x) || sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::logical_or_t logical_or_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_OR_HPP diff --git a/sprout/functional/polymorphic/mem_ptr.hpp b/sprout/functional/polymorphic/mem_ptr.hpp new file mode 100644 index 00000000..65795b27 --- /dev/null +++ b/sprout/functional/polymorphic/mem_ptr.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MEM_PTR_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_MEM_PTR_HPP + +#include +#include +#include + +namespace sprout { + // + // mem_ptr_t + // mem_ptr_ + // + struct mem_ptr_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval()->*std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval()->*std::declval())) + { + return sprout::forward(x)->*sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::mem_ptr_t mem_ptr_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MEM_PTR_HPP diff --git a/sprout/functional/polymorphic/member.hpp b/sprout/functional/polymorphic/member.hpp new file mode 100644 index 00000000..628fc32e --- /dev/null +++ b/sprout/functional/polymorphic/member.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MEMBER_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_MEMBER_HPP + +#include +#include +#include + +namespace sprout { + // + // member_t + // member_ + // + struct member_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval().*std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval().*std::declval())) + { + return sprout::forward(x).*sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::member_t member_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MEMBER_HPP diff --git a/sprout/functional/polymorphic/members.hpp b/sprout/functional/polymorphic/members.hpp new file mode 100644 index 00000000..f88bc7e7 --- /dev/null +++ b/sprout/functional/polymorphic/members.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MEMBERS_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_MEMBERS_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MEMBERS_HPP diff --git a/sprout/functional/polymorphic/minus.hpp b/sprout/functional/polymorphic/minus.hpp new file mode 100644 index 00000000..6a8c64b8 --- /dev/null +++ b/sprout/functional/polymorphic/minus.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MINUS_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_MINUS_HPP + +#include +#include +#include + +namespace sprout { + // + // minus_t + // minus_ + // + struct minus_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() - std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() - std::declval())) + { + return sprout::forward(x) - sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::minus_t minus_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MINUS_HPP diff --git a/sprout/functional/polymorphic/minus_assign.hpp b/sprout/functional/polymorphic/minus_assign.hpp new file mode 100644 index 00000000..79262d14 --- /dev/null +++ b/sprout/functional/polymorphic/minus_assign.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MINUS_ASSIGN_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_MINUS_ASSIGN_HPP + +#include +#include +#include + +namespace sprout { + // + // minus_assign_t + // minus_assign_ + // + struct minus_assign_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() -= std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() -= std::declval())) + { + return sprout::forward(x) -= sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::minus_assign_t minus_assign_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MINUS_ASSIGN_HPP diff --git a/sprout/functional/polymorphic/modulus.hpp b/sprout/functional/polymorphic/modulus.hpp new file mode 100644 index 00000000..d5cb8aa3 --- /dev/null +++ b/sprout/functional/polymorphic/modulus.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MODULUS_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_MODULUS_HPP + +#include +#include +#include + +namespace sprout { + // + // modulus_t + // modulus_ + // + struct modulus_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() % std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() % std::declval())) + { + return sprout::forward(x) % sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::modulus_t modulus_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MODULUS_HPP diff --git a/sprout/functional/polymorphic/modulus_assign.hpp b/sprout/functional/polymorphic/modulus_assign.hpp new file mode 100644 index 00000000..99bf5b53 --- /dev/null +++ b/sprout/functional/polymorphic/modulus_assign.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MODULUS_ASSIGN_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_MODULUS_ASSIGN_HPP + +#include +#include +#include + +namespace sprout { + // + // modulus_assign_t + // modulus_assign_ + // + struct modulus_assign_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() %= std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() %= std::declval())) + { + return sprout::forward(x) %= sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::modulus_assign_t modulus_assign_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MODULUS_ASSIGN_HPP diff --git a/sprout/functional/polymorphic/multiplies.hpp b/sprout/functional/polymorphic/multiplies.hpp new file mode 100644 index 00000000..886d376a --- /dev/null +++ b/sprout/functional/polymorphic/multiplies.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MULTIPLIES_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_MULTIPLIES_HPP + +#include +#include +#include + +namespace sprout { + // + // multiplies_t + // multiplies_ + // + struct multiplies_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() * std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() * std::declval())) + { + return sprout::forward(x) * sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::multiplies_t multiplies_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MULTIPLIES_HPP diff --git a/sprout/functional/polymorphic/multiplies_assign.hpp b/sprout/functional/polymorphic/multiplies_assign.hpp new file mode 100644 index 00000000..bea1ad1d --- /dev/null +++ b/sprout/functional/polymorphic/multiplies_assign.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MULTIPLIES_ASSIGN_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_MULTIPLIES_ASSIGN_HPP + +#include +#include +#include + +namespace sprout { + // + // multiplies_assign_t + // multiplies_assign_ + // + struct multiplies_assign_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() *= std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() *= std::declval())) + { + return sprout::forward(x) *= sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::multiplies_assign_t multiplies_assign_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MULTIPLIES_ASSIGN_HPP diff --git a/sprout/functional/polymorphic/negate.hpp b/sprout/functional/polymorphic/negate.hpp new file mode 100644 index 00000000..d620c10e --- /dev/null +++ b/sprout/functional/polymorphic/negate.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_NEGATE_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_NEGATE_HPP + +#include +#include +#include + +namespace sprout { + // + // negate_t + // negate_ + // + struct negate_t { + public: + template + SPROUT_CONSTEXPR decltype(-std::declval()) + operator()(T&& x) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(-std::declval())) + { + return -sprout::forward(x); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::negate_t negate_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_NEGATE_HPP diff --git a/sprout/functional/polymorphic/not_equal_to.hpp b/sprout/functional/polymorphic/not_equal_to.hpp new file mode 100644 index 00000000..0cf4af8b --- /dev/null +++ b/sprout/functional/polymorphic/not_equal_to.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_NOT_EQUAL_TO_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_NOT_EQUAL_TO_HPP + +#include +#include +#include + +namespace sprout { + // + // not_equal_to_t + // not_equal_to_ + // + struct not_equal_to_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() != std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() != std::declval())) + { + return sprout::forward(x) != sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::not_equal_to_t not_equal_to_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_NOT_EQUAL_TO_HPP diff --git a/sprout/functional/polymorphic/plus.hpp b/sprout/functional/polymorphic/plus.hpp new file mode 100644 index 00000000..fa2d20f1 --- /dev/null +++ b/sprout/functional/polymorphic/plus.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_PLUS_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_PLUS_HPP + +#include +#include +#include + +namespace sprout { + // + // plus_t + // plus_ + // + struct plus_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() + std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() + std::declval())) + { + return sprout::forward(x) + sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::plus_t plus_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_PLUS_HPP diff --git a/sprout/functional/polymorphic/plus_assign.hpp b/sprout/functional/polymorphic/plus_assign.hpp new file mode 100644 index 00000000..b4ea2110 --- /dev/null +++ b/sprout/functional/polymorphic/plus_assign.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_PLUS_ASSIGN_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_PLUS_ASSIGN_HPP + +#include +#include +#include + +namespace sprout { + // + // plus_assign_t + // plus_assign_ + // + struct plus_assign_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() += std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() += std::declval())) + { + return sprout::forward(x) += sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::plus_assign_t plus_assign_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_PLUS_ASSIGN_HPP diff --git a/sprout/functional/polymorphic/posite.hpp b/sprout/functional/polymorphic/posite.hpp new file mode 100644 index 00000000..b927f444 --- /dev/null +++ b/sprout/functional/polymorphic/posite.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_POSITE_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_POSITE_HPP + +#include +#include +#include + +namespace sprout { + // + // posite_t + // posite_ + // + struct posite_t { + public: + template + SPROUT_CONSTEXPR decltype(+std::declval()) + operator()(T&& x) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(+std::declval())) + { + return +sprout::forward(x); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::posite_t posite_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_POSITE_HPP diff --git a/sprout/functional/polymorphic/post_dec.hpp b/sprout/functional/polymorphic/post_dec.hpp new file mode 100644 index 00000000..8b888b07 --- /dev/null +++ b/sprout/functional/polymorphic/post_dec.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_POST_DEC_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_POST_DEC_HPP + +#include +#include +#include + +namespace sprout { + // + // post_dec_t + // post_dec_ + // + struct post_dec_t { + public: + template + SPROUT_CONSTEXPR decltype(~std::declval()--) + operator()(T&& x) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(~std::declval()--)) + { + return sprout::forward(x)--; + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::post_dec_t post_dec_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_POST_DEC_HPP diff --git a/sprout/functional/polymorphic/post_inc.hpp b/sprout/functional/polymorphic/post_inc.hpp new file mode 100644 index 00000000..73391237 --- /dev/null +++ b/sprout/functional/polymorphic/post_inc.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_POST_INC_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_POST_INC_HPP + +#include +#include +#include + +namespace sprout { + // + // post_inc_t + // post_inc_ + // + struct post_inc_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval()++) + operator()(T&& x) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval()++)) + { + return sprout::forward(x)++; + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::post_inc_t post_inc_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_POST_INC_HPP diff --git a/sprout/functional/polymorphic/pre_dec.hpp b/sprout/functional/polymorphic/pre_dec.hpp new file mode 100644 index 00000000..168479dd --- /dev/null +++ b/sprout/functional/polymorphic/pre_dec.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_PRE_DEC_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_PRE_DEC_HPP + +#include +#include +#include + +namespace sprout { + // + // pre_dec_t + // pre_dec_ + // + struct pre_dec_t { + public: + template + SPROUT_CONSTEXPR decltype(--std::declval()) + operator()(T&& x) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(--std::declval())) + { + return --sprout::forward(x); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::pre_dec_t pre_dec_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_PRE_DEC_HPP diff --git a/sprout/functional/polymorphic/pre_inc.hpp b/sprout/functional/polymorphic/pre_inc.hpp new file mode 100644 index 00000000..7ed0f5b4 --- /dev/null +++ b/sprout/functional/polymorphic/pre_inc.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_PRE_INC_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_PRE_INC_HPP + +#include +#include +#include + +namespace sprout { + // + // pre_inc_t + // pre_inc_ + // + struct pre_inc_t { + public: + template + SPROUT_CONSTEXPR decltype(++std::declval()) + operator()(T&& x) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(++std::declval())) + { + return ++sprout::forward(x); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::pre_inc_t pre_inc_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_PRE_INC_HPP diff --git a/sprout/functional/polymorphic/reference.hpp b/sprout/functional/polymorphic/reference.hpp new file mode 100644 index 00000000..6d4d67f9 --- /dev/null +++ b/sprout/functional/polymorphic/reference.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_REFERENCE_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_REFERENCE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_REFERENCE_HPP diff --git a/sprout/functional/polymorphic/shift_left.hpp b/sprout/functional/polymorphic/shift_left.hpp new file mode 100644 index 00000000..08543830 --- /dev/null +++ b/sprout/functional/polymorphic/shift_left.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_HPP + +#include +#include +#include + +namespace sprout { + // + // shift_left_t + // shift_left_ + // + struct shift_left_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() << std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() << std::declval())) + { + return sprout::forward(x) << sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::shift_left_t shift_left_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_HPP diff --git a/sprout/functional/polymorphic/shift_left_assign.hpp b/sprout/functional/polymorphic/shift_left_assign.hpp new file mode 100644 index 00000000..83be1784 --- /dev/null +++ b/sprout/functional/polymorphic/shift_left_assign.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_ASSIGN_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_ASSIGN_HPP + +#include +#include +#include + +namespace sprout { + // + // shift_left_assign_t + // shift_left_assign_ + // + struct shift_left_assign_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() <<= std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() <<= std::declval())) + { + return sprout::forward(x) <<= sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::shift_left_assign_t shift_left_assign_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_ASSIGN_HPP diff --git a/sprout/functional/polymorphic/shift_right.hpp b/sprout/functional/polymorphic/shift_right.hpp new file mode 100644 index 00000000..75622875 --- /dev/null +++ b/sprout/functional/polymorphic/shift_right.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_HPP + +#include +#include +#include + +namespace sprout { + // + // shift_right_t + // shift_right_ + // + struct shift_right_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() >> std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() >> std::declval())) + { + return sprout::forward(x) >> sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::shift_right_t shift_right_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_HPP diff --git a/sprout/functional/polymorphic/shift_right_assign.hpp b/sprout/functional/polymorphic/shift_right_assign.hpp new file mode 100644 index 00000000..aa8bbf49 --- /dev/null +++ b/sprout/functional/polymorphic/shift_right_assign.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_ASSIGN_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_ASSIGN_HPP + +#include +#include +#include + +namespace sprout { + // + // shift_right_assign_t + // shift_right_assign_ + // + struct shift_right_assign_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval() >>= std::declval()) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval() >>= std::declval())) + { + return sprout::forward(x) >>= sprout::forward(y); + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::shift_right_assign_t shift_right_assign_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_ASSIGN_HPP diff --git a/sprout/functional/polymorphic/subscript.hpp b/sprout/functional/polymorphic/subscript.hpp new file mode 100644 index 00000000..2fbb9858 --- /dev/null +++ b/sprout/functional/polymorphic/subscript.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SUBSCRIPT_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_SUBSCRIPT_HPP + +#include +#include +#include + +namespace sprout { + // + // subscript_t + // subscript_ + // + struct subscript_t { + public: + template + SPROUT_CONSTEXPR decltype(std::declval()[std::declval()]) + operator()(T&& x, U&& y) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval()[std::declval()])) + { + return sprout::forward(x)[sprout::forward(y)]; + } + }; + namespace { + SPROUT_STATIC_CONSTEXPR sprout::subscript_t subscript_{}; + } // anonymous-namespace +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SUBSCRIPT_HPP diff --git a/sprout/functional/polymorphic/various.hpp b/sprout/functional/polymorphic/various.hpp new file mode 100644 index 00000000..18626e0b --- /dev/null +++ b/sprout/functional/polymorphic/various.hpp @@ -0,0 +1,10 @@ +#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_VARIOUS_HPP +#define SPROUT_FUNCTIONAL_POLYMORPHIC_VARIOUS_HPP + +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_VARIOUS_HPP diff --git a/sprout/string.hpp b/sprout/string.hpp index 201dea2e..37c60bae 100644 --- a/sprout/string.hpp +++ b/sprout/string.hpp @@ -15,6 +15,5 @@ #include #include #include -#include #endif // #ifndef SPROUT_STRING_HPP diff --git a/sprout/string/tuple.hpp b/sprout/string/tuple.hpp index e139f671..3f237bf7 100644 --- a/sprout/string/tuple.hpp +++ b/sprout/string/tuple.hpp @@ -5,6 +5,34 @@ #include #include #include +#include + +namespace sprout { + namespace tuples { + // + // get + // + template + inline SPROUT_CONSTEXPR T& + get(sprout::basic_string& t) SPROUT_NOEXCEPT { + static_assert(I < N, "get: index out of range"); + return t[I]; + } + template + inline SPROUT_CONSTEXPR T const& + get(sprout::basic_string const& t) SPROUT_NOEXCEPT { + static_assert(I < N, "get: index out of range"); + return t[I]; + } + template + inline SPROUT_CONSTEXPR T&& + get(sprout::basic_string&& t) SPROUT_NOEXCEPT { + return sprout::move(sprout::tuples::get(t)); + } + } // namespace tuples + + using sprout::tuples::get; +} // namespace sprout namespace std { // diff --git a/sprout/tuple/array.hpp b/sprout/tuple/array.hpp index 62b31bcf..38209ef9 100644 --- a/sprout/tuple/array.hpp +++ b/sprout/tuple/array.hpp @@ -1,36 +1,7 @@ #ifndef SPROUT_TUPLE_ARRAY_HPP #define SPROUT_TUPLE_ARRAY_HPP -#include -#include #include #include -namespace sprout { - namespace tuples { - // - // get - // - template - inline SPROUT_CONSTEXPR T& - get(sprout::array& t) SPROUT_NOEXCEPT { - static_assert(I < N, "get: index out of range"); - return t[I]; - } - template - inline SPROUT_CONSTEXPR T const& - get(sprout::array const& t) SPROUT_NOEXCEPT { - static_assert(I < N, "get: index out of range"); - return t[I]; - } - template - inline SPROUT_CONSTEXPR T&& - get(sprout::array&& t) SPROUT_NOEXCEPT { - return sprout::move(sprout::tuples::get(t)); - } - } // namespace tuples - - using sprout::tuples::get; -} // namespace sprout - #endif // #ifndef SPROUT_TUPLE_ARRAY_HPP diff --git a/sprout/tuple/string.hpp b/sprout/tuple/string.hpp index f5af5891..feb014c2 100644 --- a/sprout/tuple/string.hpp +++ b/sprout/tuple/string.hpp @@ -1,37 +1,7 @@ #ifndef SPROUT_TUPLE_STRING_HPP #define SPROUT_TUPLE_STRING_HPP -#include -#include #include -#include -#include - -namespace sprout { - namespace tuples { - // - // get - // - template - inline SPROUT_CONSTEXPR T& - get(sprout::basic_string& t) SPROUT_NOEXCEPT { - static_assert(I < N, "get: index out of range"); - return t[I]; - } - template - inline SPROUT_CONSTEXPR T const& - get(sprout::basic_string const& t) SPROUT_NOEXCEPT { - static_assert(I < N, "get: index out of range"); - return t[I]; - } - template - inline SPROUT_CONSTEXPR T&& - get(sprout::basic_string&& t) SPROUT_NOEXCEPT { - return sprout::move(sprout::tuples::get(t)); - } - } // namespace tuples - - using sprout::tuples::get; -} // namespace sprout +#include #endif // #ifndef SPROUT_TUPLE_STRING_HPP