add functional/polymorphic.hpp

This commit is contained in:
bolero-MURAKAMI 2012-06-21 13:34:26 +09:00
parent 71b6e89f92
commit 3a2610cb5c
66 changed files with 1537 additions and 63 deletions

View file

@ -12,6 +12,7 @@
#include <sprout/container/functions.hpp>
#include <sprout/iterator.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/move.hpp>
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
#if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION
# include <sprout/iterator/index_iterator.hpp>
@ -286,6 +287,31 @@ namespace sprout {
struct is_array<sprout::array<T, N> >
: public std::true_type
{};
namespace tuples {
//
// get
//
template<std::size_t I, typename T, std::size_t N>
inline SPROUT_CONSTEXPR T&
get(sprout::array<T, N>& t) SPROUT_NOEXCEPT {
static_assert(I < N, "get: index out of range");
return t[I];
}
template<std::size_t I, typename T, std::size_t N>
inline SPROUT_CONSTEXPR T const&
get(sprout::array<T, N> const& t) SPROUT_NOEXCEPT {
static_assert(I < N, "get: index out of range");
return t[I];
}
template<std::size_t I, typename T, std::size_t N>
inline SPROUT_CONSTEXPR T&&
get(sprout::array<T, N>&& t) SPROUT_NOEXCEPT {
return sprout::move(sprout::tuples::get<I>(t));
}
} // namespace tuples
using sprout::tuples::get;
} // namespace sprout
namespace std {
@ -308,6 +334,4 @@ namespace std {
};
} // namespace std
#include <sprout/tuple/array.hpp>
#endif // #ifndef SPROUT_ARRAY_HPP

View file

@ -9,5 +9,6 @@
#include <sprout/functional/mem_fn.hpp>
#include <sprout/functional/bind.hpp>
#include <sprout/functional/hash.hpp>
#include <sprout/functional/polymorphic.hpp>
#endif // #ifndef SPROUT_FUNCTIONAL_HPP

View file

@ -0,0 +1,15 @@
#ifndef SPROUT_FUNCTIONAL_HASH_PIT_HPP
#define SPROUT_FUNCTIONAL_HASH_PIT_HPP
#include <sprout/config.hpp>
#include <sprout/functional/hash/hash.hpp>
#include <sprout/pit.hpp>
namespace sprout {
template<typename Container>
SPROUT_CONSTEXPR std::size_t hash_value(sprout::pit<Container> const& v) {
return sprout::to_hash(v.elem);
}
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_PIT_HPP

View file

@ -0,0 +1,7 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_HPP
#include <sprout/config.hpp>
#include <sprout/functional/polymorphic/functor.hpp>
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_ADDRESS_OF_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_ADDRESS_OF_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// address_of_t
// address_of_
//
struct address_of_t {
public:
template<typename T>
SPROUT_CONSTEXPR decltype(&std::declval<T>())
operator()(T&& x)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(&std::declval<T>()))
{
return &sprout::forward<T>(x);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::address_of_t address_of_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_ADDRESS_OF_HPP

View file

@ -0,0 +1,13 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_ARITHMETIC_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_ARITHMETIC_HPP
#include <sprout/config.hpp>
#include <sprout/functional/polymorphic/plus.hpp>
#include <sprout/functional/polymorphic/minus.hpp>
#include <sprout/functional/polymorphic/multiplies.hpp>
#include <sprout/functional/polymorphic/divides.hpp>
#include <sprout/functional/polymorphic/modulus.hpp>
#include <sprout/functional/polymorphic/negate.hpp>
#include <sprout/functional/polymorphic/posite.hpp>
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_ARITHMETIC_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_ASSIGN_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_ASSIGN_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// assign_t
// assign_
//
struct assign_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() = std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() = std::declval<U>()))
{
return sprout::forward<T>(x) = sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::assign_t assign_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_ASSIGN_HPP

View file

@ -0,0 +1,16 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_ASSIGNMENT_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_ASSIGNMENT_HPP
#include <sprout/config.hpp>
#include <sprout/functional/polymorphic/plus_assign.hpp>
#include <sprout/functional/polymorphic/minus_assign.hpp>
#include <sprout/functional/polymorphic/multiplies_assign.hpp>
#include <sprout/functional/polymorphic/divides_assign.hpp>
#include <sprout/functional/polymorphic/modulus_assign.hpp>
#include <sprout/functional/polymorphic/bit_and_assign.hpp>
#include <sprout/functional/polymorphic/bit_or_assign.hpp>
#include <sprout/functional/polymorphic/bit_xor_assign.hpp>
#include <sprout/functional/polymorphic/shift_left_assign.hpp>
#include <sprout/functional/polymorphic/shift_right_assign.hpp>
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_ASSIGNMENT_HPP

View file

@ -0,0 +1,39 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIND1ST_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIND1ST_HPP
#include <utility>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// binder1st_
// bind1st_
//
template<typename Fn, typename T>
class binder1st_ {
protected:
Fn op;
T value;
public:
SPROUT_CONSTEXPR binder1st_(Fn&& x, T&& y)
: op(sprout::forward<Fn>(x)), value(sprout::forward<T>(y))
{}
template<typename Arg>
SPROUT_CONSTEXPR decltype(op(value, std::declval<Arg>()))
operator()(Arg&& x)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(op(value, std::declval<Arg>())))
{
return op(value, sprout::forward<Arg>(x));
}
};
template<typename Fn, typename T>
SPROUT_CONSTEXPR sprout::binder1st_<typename std::decay<Fn>::type, typename std::decay<T>::type>
bind1st_(Fn&& fn, T&& x) {
typedef sprout::binder1st_<typename std::decay<Fn>::type, typename std::decay<T>::type> type;
return type(sprout::forward<Fn>(fn), sprout::forward<T>(x));
}
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIND1ST_HPP

View file

@ -0,0 +1,39 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIND2ND_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIND2ND_HPP
#include <utility>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// binder2nd_
// bind2nd_
//
template<typename Fn, typename T>
class binder2nd_ {
protected:
Fn op;
T value;
public:
SPROUT_CONSTEXPR binder2nd_(Fn&& x, T&& y)
: op(sprout::forward<Fn>(x)), value(sprout::forward<T>(y))
{}
template<typename Arg>
SPROUT_CONSTEXPR decltype(op(std::declval<Arg>(), value))
operator()(Arg&& x)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(op(std::declval<Arg>(), value)))
{
return op(sprout::forward<Arg>(x), value);
}
};
template<typename Fn, typename T>
SPROUT_CONSTEXPR sprout::binder2nd_<typename std::decay<Fn>::type, typename std::decay<T>::type>
bind2nd_(Fn&& fn, T&& x) {
typedef sprout::binder2nd_<typename std::decay<Fn>::type, typename std::decay<T>::type> type;
return type(sprout::forward<Fn>(fn), sprout::forward<T>(x));
}
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIND2ND_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BINDER_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_BINDER_HPP
#include <sprout/config.hpp>
#include <sprout/functional/polymorphic/bind1st.hpp>
#include <sprout/functional/polymorphic/bind2nd.hpp>
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BINDER_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_AND_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_AND_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// bit_and_t
// bit_and_
//
struct bit_and_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() & std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() & std::declval<U>()))
{
return sprout::forward<T>(x) & sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::bit_and_t bit_and_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_AND_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_AND_ASSIGN_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_AND_ASSIGN_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// bit_and_assign_t
// bit_and_assign_
//
struct bit_and_assign_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() &= std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() &= std::declval<U>()))
{
return sprout::forward<T>(x) &= sprout::forward<U>(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

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_NOT_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_NOT_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// bit_not_t
// bit_not_
//
struct bit_not_t {
public:
template<typename T>
SPROUT_CONSTEXPR decltype(~std::declval<T>())
operator()(T&& x)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(~std::declval<T>()))
{
return ~sprout::forward<T>(x);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::bit_not_t bit_not_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_NOT_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_OR_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_OR_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// bit_or_t
// bit_or_
//
struct bit_or_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() | std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() | std::declval<U>()))
{
return sprout::forward<T>(x) | sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::bit_or_t bit_or_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_OR_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_OR_ASSIGN_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_OR_ASSIGN_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// bit_or_assign_t
// bit_or_assign_
//
struct bit_or_assign_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() |= std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() |= std::declval<U>()))
{
return sprout::forward<T>(x) |= sprout::forward<U>(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

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_XOR_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_XOR_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// bit_xor_t
// bit_xor_
//
struct bit_xor_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() ^ std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() ^ std::declval<U>()))
{
return sprout::forward<T>(x) ^ sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::bit_xor_t bit_xor_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_XOR_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_XOR_ASSIGN_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_BIT_XOR_ASSIGN_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// bit_xor_assign_t
// bit_xor_assign_
//
struct bit_xor_assign_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() ^= std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() ^= std::declval<U>()))
{
return sprout::forward<T>(x) ^= sprout::forward<U>(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

View file

@ -0,0 +1,12 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BITWISE_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_BITWISE_HPP
#include <sprout/config.hpp>
#include <sprout/functional/polymorphic/bit_and.hpp>
#include <sprout/functional/polymorphic/bit_or.hpp>
#include <sprout/functional/polymorphic/bit_xor.hpp>
#include <sprout/functional/polymorphic/bit_not.hpp>
#include <sprout/functional/polymorphic/shift_left.hpp>
#include <sprout/functional/polymorphic/shift_right.hpp>
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_BITWISE_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_CALL_FUN_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_CALL_FUN_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// call_fun_t
// call_fun_
//
struct call_fun_t {
public:
template<typename F, typename... As>
SPROUT_CONSTEXPR decltype(std::declval<F>()(std::declval<As>()...))
operator()(F&& f, As&&... as)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<F>()(std::declval<As>()...)))
{
return sprout::forward<F>(f)(sprout::forward<As>(as)...);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::call_fun_t call_fun_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_CALL_FUN_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_COMMA_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_COMMA_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// comma_t
// comma_
//
struct comma_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>(), std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR((std::declval<T>(), std::declval<U>())))
{
return sprout::forward<T>(x), sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::comma_t comma_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_COMMA_HPP

View file

@ -0,0 +1,12 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_COMPARISON_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_COMPARISON_HPP
#include <sprout/config.hpp>
#include <sprout/functional/polymorphic/equal_to.hpp>
#include <sprout/functional/polymorphic/not_equal_to.hpp>
#include <sprout/functional/polymorphic/greater.hpp>
#include <sprout/functional/polymorphic/less.hpp>
#include <sprout/functional/polymorphic/greater_equal.hpp>
#include <sprout/functional/polymorphic/less_equal.hpp>
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_COMPARISON_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_COND_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_COND_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// cond_t
// cond_
//
struct cond_t {
public:
template<typename T, typename U, typename V>
SPROUT_CONSTEXPR decltype(std::declval<T>() ? std::declval<U>() : std::declval<V>())
operator()(T&& x, U&& y, V&& z)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() ? std::declval<U>() : std::declval<V>()))
{
return sprout::forward<T>(x) ? sprout::forward<U>(y) : sprout::forward<V>(z);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::cond_t cond_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_COND_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_DEREFERENCE_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_DEREFERENCE_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// dereference_t
// dereference_
//
struct dereference_t {
public:
template<typename T>
SPROUT_CONSTEXPR decltype(*std::declval<T>())
operator()(T&& x)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(*std::declval<T>()))
{
return *sprout::forward<T>(x);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::dereference_t dereference_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_DEREFERENCE_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_DEVIDES_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_DEVIDES_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// divides_t
// divides_
//
struct divides_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() / std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() / std::declval<U>()))
{
return sprout::forward<T>(x) / sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::divides_t divides_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_DEVIDES_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_DEVIDES_ASSIGN_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_DEVIDES_ASSIGN_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// divides_assign_t
// divides_assign_
//
struct divides_assign_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() /= std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() /= std::declval<U>()))
{
return sprout::forward<T>(x) /= sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::divides_assign_t divides_assign_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_DEVIDES_ASSIGN_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_EQUAL_TO_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_EQUAL_TO_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// equal_to_t
// equal_to_
//
struct equal_to_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() == std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() == std::declval<U>()))
{
return sprout::forward<T>(x) == sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::equal_to_t equal_to_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_EQUAL_TO_HPP

View file

@ -0,0 +1,15 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_FUNCTOR_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_FUNCTOR_HPP
#include <sprout/config.hpp>
#include <sprout/functional/polymorphic/arithmetic.hpp>
#include <sprout/functional/polymorphic/comparison.hpp>
#include <sprout/functional/polymorphic/logical.hpp>
#include <sprout/functional/polymorphic/bitwise.hpp>
#include <sprout/functional/polymorphic/inc_dec.hpp>
#include <sprout/functional/polymorphic/assignment.hpp>
#include <sprout/functional/polymorphic/members.hpp>
#include <sprout/functional/polymorphic/various.hpp>
#include <sprout/functional/polymorphic/binder.hpp>
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_FUNCTOR_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_GREATER_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_GREATER_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// greater_t
// greater_
//
struct greater_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() > std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() > std::declval<U>()))
{
return sprout::forward<T>(x) > sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::greater_t greater_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_GREATER_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_GREATER_EQUAL_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_GREATER_EQUAL_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// greater_equal_t
// greater_equal_
//
struct greater_equal_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() >= std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() >= std::declval<U>()))
{
return sprout::forward<T>(x) >= sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::greater_equal_t greater_equal_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_GREATER_EQUAL_HPP

View file

@ -0,0 +1,10 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_INC_DEC_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_INC_DEC_HPP
#include <sprout/config.hpp>
#include <sprout/functional/polymorphic/pre_inc.hpp>
#include <sprout/functional/polymorphic/pre_dec.hpp>
#include <sprout/functional/polymorphic/post_inc.hpp>
#include <sprout/functional/polymorphic/post_dec.hpp>
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_INC_DEC_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LESS_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_LESS_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// less_t
// less_
//
struct less_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() < std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() < std::declval<U>()))
{
return sprout::forward<T>(x) < sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::less_t less_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LESS_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LESS_EQUAL_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_LESS_EQUAL_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// less_equal_t
// less_equal_
//
struct less_equal_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() <= std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() <= std::declval<U>()))
{
return sprout::forward<T>(x) <= sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::less_equal_t less_equal_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LESS_EQUAL_HPP

View file

@ -0,0 +1,9 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_HPP
#include <sprout/config.hpp>
#include <sprout/functional/polymorphic/logical_and.hpp>
#include <sprout/functional/polymorphic/logical_or.hpp>
#include <sprout/functional/polymorphic/logical_not.hpp>
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_AND_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_AND_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// logical_and_t
// logical_and_
//
struct logical_and_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() && std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() && std::declval<U>()))
{
return sprout::forward<T>(x) && sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::logical_and_t logical_and_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_AND_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_NOT_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_NOT_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// logical_not_t
// logical_not_
//
struct logical_not_t {
public:
template<typename T>
SPROUT_CONSTEXPR decltype(!std::declval<T>())
operator()(T&& x)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(!std::declval<T>()))
{
return !sprout::forward<T>(x);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::logical_not_t logical_not_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_NOT_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_OR_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_OR_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// logical_or_t
// logical_or_
//
struct logical_or_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() || std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() || std::declval<U>()))
{
return sprout::forward<T>(x) || sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::logical_or_t logical_or_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_LOGICAL_OR_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MEM_PTR_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_MEM_PTR_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// mem_ptr_t
// mem_ptr_
//
struct mem_ptr_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>()->*std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>()->*std::declval<U>()))
{
return sprout::forward<T>(x)->*sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::mem_ptr_t mem_ptr_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MEM_PTR_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MEMBER_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_MEMBER_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// member_t
// member_
//
struct member_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>().*std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>().*std::declval<U>()))
{
return sprout::forward<T>(x).*sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::member_t member_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MEMBER_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MEMBERS_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_MEMBERS_HPP
#include <sprout/config.hpp>
#include <sprout/functional/polymorphic/mem_ptr.hpp>
#include <sprout/functional/polymorphic/member.hpp>
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MEMBERS_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MINUS_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_MINUS_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// minus_t
// minus_
//
struct minus_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() - std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() - std::declval<U>()))
{
return sprout::forward<T>(x) - sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::minus_t minus_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MINUS_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MINUS_ASSIGN_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_MINUS_ASSIGN_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// minus_assign_t
// minus_assign_
//
struct minus_assign_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() -= std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() -= std::declval<U>()))
{
return sprout::forward<T>(x) -= sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::minus_assign_t minus_assign_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MINUS_ASSIGN_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MODULUS_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_MODULUS_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// modulus_t
// modulus_
//
struct modulus_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() % std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() % std::declval<U>()))
{
return sprout::forward<T>(x) % sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::modulus_t modulus_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MODULUS_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MODULUS_ASSIGN_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_MODULUS_ASSIGN_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// modulus_assign_t
// modulus_assign_
//
struct modulus_assign_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() %= std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() %= std::declval<U>()))
{
return sprout::forward<T>(x) %= sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::modulus_assign_t modulus_assign_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MODULUS_ASSIGN_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MULTIPLIES_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_MULTIPLIES_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// multiplies_t
// multiplies_
//
struct multiplies_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() * std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() * std::declval<U>()))
{
return sprout::forward<T>(x) * sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::multiplies_t multiplies_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MULTIPLIES_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MULTIPLIES_ASSIGN_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_MULTIPLIES_ASSIGN_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// multiplies_assign_t
// multiplies_assign_
//
struct multiplies_assign_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() *= std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() *= std::declval<U>()))
{
return sprout::forward<T>(x) *= sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::multiplies_assign_t multiplies_assign_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_MULTIPLIES_ASSIGN_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_NEGATE_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_NEGATE_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// negate_t
// negate_
//
struct negate_t {
public:
template<typename T>
SPROUT_CONSTEXPR decltype(-std::declval<T>())
operator()(T&& x)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(-std::declval<T>()))
{
return -sprout::forward<T>(x);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::negate_t negate_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_NEGATE_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_NOT_EQUAL_TO_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_NOT_EQUAL_TO_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// not_equal_to_t
// not_equal_to_
//
struct not_equal_to_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() != std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() != std::declval<U>()))
{
return sprout::forward<T>(x) != sprout::forward<U>(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

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_PLUS_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_PLUS_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// plus_t
// plus_
//
struct plus_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() + std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() + std::declval<U>()))
{
return sprout::forward<T>(x) + sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::plus_t plus_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_PLUS_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_PLUS_ASSIGN_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_PLUS_ASSIGN_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// plus_assign_t
// plus_assign_
//
struct plus_assign_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() += std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() += std::declval<U>()))
{
return sprout::forward<T>(x) += sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::plus_assign_t plus_assign_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_PLUS_ASSIGN_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_POSITE_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_POSITE_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// posite_t
// posite_
//
struct posite_t {
public:
template<typename T>
SPROUT_CONSTEXPR decltype(+std::declval<T>())
operator()(T&& x)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(+std::declval<T>()))
{
return +sprout::forward<T>(x);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::posite_t posite_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_POSITE_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_POST_DEC_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_POST_DEC_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// post_dec_t
// post_dec_
//
struct post_dec_t {
public:
template<typename T>
SPROUT_CONSTEXPR decltype(~std::declval<T>()--)
operator()(T&& x)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(~std::declval<T>()--))
{
return sprout::forward<T>(x)--;
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::post_dec_t post_dec_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_POST_DEC_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_POST_INC_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_POST_INC_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// post_inc_t
// post_inc_
//
struct post_inc_t {
public:
template<typename T>
SPROUT_CONSTEXPR decltype(std::declval<T>()++)
operator()(T&& x)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>()++))
{
return sprout::forward<T>(x)++;
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::post_inc_t post_inc_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_POST_INC_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_PRE_DEC_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_PRE_DEC_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// pre_dec_t
// pre_dec_
//
struct pre_dec_t {
public:
template<typename T>
SPROUT_CONSTEXPR decltype(--std::declval<T>())
operator()(T&& x)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(--std::declval<T>()))
{
return --sprout::forward<T>(x);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::pre_dec_t pre_dec_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_PRE_DEC_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_PRE_INC_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_PRE_INC_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// pre_inc_t
// pre_inc_
//
struct pre_inc_t {
public:
template<typename T>
SPROUT_CONSTEXPR decltype(++std::declval<T>())
operator()(T&& x)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(++std::declval<T>()))
{
return ++sprout::forward<T>(x);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::pre_inc_t pre_inc_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_PRE_INC_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_REFERENCE_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_REFERENCE_HPP
#include <sprout/config.hpp>
#include <sprout/functional/polymorphic/address_of.hpp>
#include <sprout/functional/polymorphic/dereference.hpp>
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_REFERENCE_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// shift_left_t
// shift_left_
//
struct shift_left_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() << std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() << std::declval<U>()))
{
return sprout::forward<T>(x) << sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::shift_left_t shift_left_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_ASSIGN_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_ASSIGN_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// shift_left_assign_t
// shift_left_assign_
//
struct shift_left_assign_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() <<= std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() <<= std::declval<U>()))
{
return sprout::forward<T>(x) <<= sprout::forward<U>(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

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// shift_right_t
// shift_right_
//
struct shift_right_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() >> std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() >> std::declval<U>()))
{
return sprout::forward<T>(x) >> sprout::forward<U>(y);
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::shift_right_t shift_right_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_ASSIGN_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_SHIFT_LEFT_ASSIGN_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// shift_right_assign_t
// shift_right_assign_
//
struct shift_right_assign_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>() >>= std::declval<U>())
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>() >>= std::declval<U>()))
{
return sprout::forward<T>(x) >>= sprout::forward<U>(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

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SUBSCRIPT_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_SUBSCRIPT_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// subscript_t
// subscript_
//
struct subscript_t {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(std::declval<T>()[std::declval<U>()])
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<T>()[std::declval<U>()]))
{
return sprout::forward<T>(x)[sprout::forward<U>(y)];
}
};
namespace {
SPROUT_STATIC_CONSTEXPR sprout::subscript_t subscript_{};
} // anonymous-namespace
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_SUBSCRIPT_HPP

View file

@ -0,0 +1,10 @@
#ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_VARIOUS_HPP
#define SPROUT_FUNCTIONAL_POLYMORPHIC_VARIOUS_HPP
#include <sprout/config.hpp>
#include <sprout/functional/polymorphic/subscript.hpp>
#include <sprout/functional/polymorphic/call_fun.hpp>
#include <sprout/functional/polymorphic/cond.hpp>
#include <sprout/functional/polymorphic/comma.hpp>
#endif // #ifndef SPROUT_FUNCTIONAL_POLYMORPHIC_VARIOUS_HPP

View file

@ -15,6 +15,5 @@
#include <sprout/string/type_traits.hpp>
#include <sprout/string/alias.hpp>
#include <sprout/string/shrink.hpp>
#include <sprout/tuple/string.hpp>
#endif // #ifndef SPROUT_STRING_HPP

View file

@ -5,6 +5,34 @@
#include <tuple>
#include <type_traits>
#include <sprout/string/string.hpp>
#include <sprout/utility/move.hpp>
namespace sprout {
namespace tuples {
//
// get
//
template<std::size_t I, typename T, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR T&
get(sprout::basic_string<T, N, Traits>& t) SPROUT_NOEXCEPT {
static_assert(I < N, "get: index out of range");
return t[I];
}
template<std::size_t I, typename T, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR T const&
get(sprout::basic_string<T, N, Traits> const& t) SPROUT_NOEXCEPT {
static_assert(I < N, "get: index out of range");
return t[I];
}
template<std::size_t I, typename T, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR T&&
get(sprout::basic_string<T, N, Traits>&& t) SPROUT_NOEXCEPT {
return sprout::move(sprout::tuples::get<I>(t));
}
} // namespace tuples
using sprout::tuples::get;
} // namespace sprout
namespace std {
//

View file

@ -1,36 +1,7 @@
#ifndef SPROUT_TUPLE_ARRAY_HPP
#define SPROUT_TUPLE_ARRAY_HPP
#include <cstddef>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/array.hpp>
namespace sprout {
namespace tuples {
//
// get
//
template<std::size_t I, typename T, std::size_t N>
inline SPROUT_CONSTEXPR T&
get(sprout::array<T, N>& t) SPROUT_NOEXCEPT {
static_assert(I < N, "get: index out of range");
return t[I];
}
template<std::size_t I, typename T, std::size_t N>
inline SPROUT_CONSTEXPR T const&
get(sprout::array<T, N> const& t) SPROUT_NOEXCEPT {
static_assert(I < N, "get: index out of range");
return t[I];
}
template<std::size_t I, typename T, std::size_t N>
inline SPROUT_CONSTEXPR T&&
get(sprout::array<T, N>&& t) SPROUT_NOEXCEPT {
return sprout::move(sprout::tuples::get<I>(t));
}
} // namespace tuples
using sprout::tuples::get;
} // namespace sprout
#endif // #ifndef SPROUT_TUPLE_ARRAY_HPP

View file

@ -1,37 +1,7 @@
#ifndef SPROUT_TUPLE_STRING_HPP
#define SPROUT_TUPLE_STRING_HPP
#include <cstddef>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/utility/move.hpp>
#include <sprout/string.hpp>
namespace sprout {
namespace tuples {
//
// get
//
template<std::size_t I, typename T, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR T&
get(sprout::basic_string<T, N, Traits>& t) SPROUT_NOEXCEPT {
static_assert(I < N, "get: index out of range");
return t[I];
}
template<std::size_t I, typename T, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR T const&
get(sprout::basic_string<T, N, Traits> const& t) SPROUT_NOEXCEPT {
static_assert(I < N, "get: index out of range");
return t[I];
}
template<std::size_t I, typename T, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR T&&
get(sprout::basic_string<T, N, Traits>&& t) SPROUT_NOEXCEPT {
return sprout::move(sprout::tuples::get<I>(t));
}
} // namespace tuples
using sprout::tuples::get;
} // namespace sprout
#include <sprout/string/tuple.hpp>
#endif // #ifndef SPROUT_TUPLE_STRING_HPP