add functional polymorphic specializations

This commit is contained in:
bolero-MURAKAMI 2012-10-25 12:50:03 +09:00
parent 5cb070b3b3
commit c8e2514d36
21 changed files with 300 additions and 19 deletions

View file

@ -1,11 +1,13 @@
#ifndef SPROUT_FUNCTIONAL_BIT_AND_HPP #ifndef SPROUT_FUNCTIONAL_BIT_AND_HPP
#define SPROUT_FUNCTIONAL_BIT_AND_HPP #define SPROUT_FUNCTIONAL_BIT_AND_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// 20.8.7 bitwise operations // 20.8.7 bitwise operations
template<typename T> template<typename T = void>
struct bit_and { struct bit_and {
public: public:
typedef T first_argument_type; typedef T first_argument_type;
@ -16,6 +18,18 @@ namespace sprout {
return x & y; return x & y;
} }
}; };
template<>
struct bit_and<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_BIT_AND_HPP #endif // #ifndef SPROUT_FUNCTIONAL_BIT_AND_HPP

View file

@ -1,11 +1,13 @@
#ifndef SPROUT_FUNCTIONAL_BIT_NOT_HPP #ifndef SPROUT_FUNCTIONAL_BIT_NOT_HPP
#define SPROUT_FUNCTIONAL_BIT_NOT_HPP #define SPROUT_FUNCTIONAL_BIT_NOT_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// 20.8.7 bitwise operations // 20.8.7 bitwise operations
template<typename T> template<typename T = void>
struct bit_not { struct bit_not {
public: public:
typedef T argument_type; typedef T argument_type;
@ -15,6 +17,18 @@ namespace sprout {
return ~x; return ~x;
} }
}; };
template<>
struct bit_not<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_BIT_NOT_HPP #endif // #ifndef SPROUT_FUNCTIONAL_BIT_NOT_HPP

View file

@ -1,11 +1,13 @@
#ifndef SPROUT_FUNCTIONAL_BIT_OR_HPP #ifndef SPROUT_FUNCTIONAL_BIT_OR_HPP
#define SPROUT_FUNCTIONAL_BIT_OR_HPP #define SPROUT_FUNCTIONAL_BIT_OR_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// 20.8.7 bitwise operations // 20.8.7 bitwise operations
template<typename T> template<typename T = void>
struct bit_or { struct bit_or {
public: public:
typedef T first_argument_type; typedef T first_argument_type;
@ -16,6 +18,18 @@ namespace sprout {
return x | y; return x | y;
} }
}; };
template<>
struct bit_or<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_BIT_OR_HPP #endif // #ifndef SPROUT_FUNCTIONAL_BIT_OR_HPP

View file

@ -1,11 +1,13 @@
#ifndef SPROUT_FUNCTIONAL_BIT_XOR_HPP #ifndef SPROUT_FUNCTIONAL_BIT_XOR_HPP
#define SPROUT_FUNCTIONAL_BIT_XOR_HPP #define SPROUT_FUNCTIONAL_BIT_XOR_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// 20.8.7 bitwise operations // 20.8.7 bitwise operations
template<typename T> template<typename T = void>
struct bit_xor { struct bit_xor {
public: public:
typedef T first_argument_type; typedef T first_argument_type;
@ -16,6 +18,18 @@ namespace sprout {
return x ^ y; return x ^ y;
} }
}; };
template<>
struct bit_xor<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_BIT_XOR_HPP #endif // #ifndef SPROUT_FUNCTIONAL_BIT_XOR_HPP

View file

@ -1,13 +1,15 @@
#ifndef SPROUT_FUNCTIONAL_DEVIDES_HPP #ifndef SPROUT_FUNCTIONAL_DEVIDES_HPP
#define SPROUT_FUNCTIONAL_DEVIDES_HPP #define SPROUT_FUNCTIONAL_DEVIDES_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk) // Copyright (C) 2011 RiSK (sscrisk)
// 20.8.4 Arithmetic operations // 20.8.4 Arithmetic operations
template<typename T> template<typename T = void>
struct divides { struct divides {
public: public:
typedef T first_argument_type; typedef T first_argument_type;
@ -18,6 +20,18 @@ namespace sprout {
return x / y; return x / y;
} }
}; };
template<>
struct divides<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_DEVIDES_HPP #endif // #ifndef SPROUT_FUNCTIONAL_DEVIDES_HPP

View file

@ -1,13 +1,15 @@
#ifndef SPROUT_FUNCTIONAL_EQUAL_TO_HPP #ifndef SPROUT_FUNCTIONAL_EQUAL_TO_HPP
#define SPROUT_FUNCTIONAL_EQUAL_TO_HPP #define SPROUT_FUNCTIONAL_EQUAL_TO_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk) // Copyright (C) 2011 RiSK (sscrisk)
// 20.8.5 Comparisons // 20.8.5 Comparisons
template<typename T> template<typename T = void>
struct equal_to { struct equal_to {
public: public:
typedef T first_argument_type; typedef T first_argument_type;
@ -18,6 +20,18 @@ namespace sprout {
return x == y; return x == y;
} }
}; };
template<>
struct equal_to<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_EQUAL_TO_HPP #endif // #ifndef SPROUT_FUNCTIONAL_EQUAL_TO_HPP

View file

@ -1,13 +1,15 @@
#ifndef SPROUT_FUNCTIONAL_GREATER_HPP #ifndef SPROUT_FUNCTIONAL_GREATER_HPP
#define SPROUT_FUNCTIONAL_GREATER_HPP #define SPROUT_FUNCTIONAL_GREATER_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk) // Copyright (C) 2011 RiSK (sscrisk)
// 20.8.5 Comparisons // 20.8.5 Comparisons
template<typename T> template<typename T = void>
struct greater { struct greater {
public: public:
typedef T first_argument_type; typedef T first_argument_type;
@ -18,6 +20,18 @@ namespace sprout {
return x > y; return x > y;
} }
}; };
template<>
struct greater<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_GREATER_HPP #endif // #ifndef SPROUT_FUNCTIONAL_GREATER_HPP

View file

@ -1,13 +1,15 @@
#ifndef SPROUT_FUNCTIONAL_GREATER_EQUAL_HPP #ifndef SPROUT_FUNCTIONAL_GREATER_EQUAL_HPP
#define SPROUT_FUNCTIONAL_GREATER_EQUAL_HPP #define SPROUT_FUNCTIONAL_GREATER_EQUAL_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk) // Copyright (C) 2011 RiSK (sscrisk)
// 20.8.5 Comparisons // 20.8.5 Comparisons
template<typename T> template<typename T = void>
struct greater_equal { struct greater_equal {
public: public:
typedef T first_argument_type; typedef T first_argument_type;
@ -18,6 +20,18 @@ namespace sprout {
return x >= y; return x >= y;
} }
}; };
template<>
struct greater_equal<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_GREATER_EQUAL_HPP #endif // #ifndef SPROUT_FUNCTIONAL_GREATER_EQUAL_HPP

View file

@ -1,13 +1,15 @@
#ifndef SPROUT_FUNCTIONAL_LESS_HPP #ifndef SPROUT_FUNCTIONAL_LESS_HPP
#define SPROUT_FUNCTIONAL_LESS_HPP #define SPROUT_FUNCTIONAL_LESS_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk) // Copyright (C) 2011 RiSK (sscrisk)
// 20.8.5 Comparisons // 20.8.5 Comparisons
template<typename T> template<typename T = void>
struct less { struct less {
public: public:
typedef T first_argument_type; typedef T first_argument_type;
@ -18,6 +20,18 @@ namespace sprout {
return x < y; return x < y;
} }
}; };
template<>
struct less<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_LESS_HPP #endif // #ifndef SPROUT_FUNCTIONAL_LESS_HPP

View file

@ -1,7 +1,9 @@
#ifndef SPROUT_FUNCTIONAL_LESS_EQUAL_HPP #ifndef SPROUT_FUNCTIONAL_LESS_EQUAL_HPP
#define SPROUT_FUNCTIONAL_LESS_EQUAL_HPP #define SPROUT_FUNCTIONAL_LESS_EQUAL_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk) // Copyright (C) 2011 RiSK (sscrisk)
@ -18,6 +20,18 @@ namespace sprout {
return x <= y; return x <= y;
} }
}; };
template<>
struct less_equal<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_LESS_EQUAL_HPP #endif // #ifndef SPROUT_FUNCTIONAL_LESS_EQUAL_HPP

View file

@ -1,11 +1,13 @@
#ifndef SPROUT_FUNCTIONAL_LOGICAL_AND_HPP #ifndef SPROUT_FUNCTIONAL_LOGICAL_AND_HPP
#define SPROUT_FUNCTIONAL_LOGICAL_AND_HPP #define SPROUT_FUNCTIONAL_LOGICAL_AND_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// 20.8.6 logical operations // 20.8.6 logical operations
template<typename T> template<typename T = void>
struct logical_and { struct logical_and {
public: public:
typedef T first_argument_type; typedef T first_argument_type;
@ -16,6 +18,18 @@ namespace sprout {
return x && y; return x && y;
} }
}; };
template<>
struct logical_and<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_LOGICAL_AND_HPP #endif // #ifndef SPROUT_FUNCTIONAL_LOGICAL_AND_HPP

View file

@ -1,11 +1,13 @@
#ifndef SPROUT_FUNCTIONAL_LOGICAL_NOT_HPP #ifndef SPROUT_FUNCTIONAL_LOGICAL_NOT_HPP
#define SPROUT_FUNCTIONAL_LOGICAL_NOT_HPP #define SPROUT_FUNCTIONAL_LOGICAL_NOT_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// 20.8.6 logical operations // 20.8.6 logical operations
template<typename T> template<typename T = void>
struct logical_not { struct logical_not {
public: public:
typedef T argument_type; typedef T argument_type;
@ -15,6 +17,18 @@ namespace sprout {
return !x; return !x;
} }
}; };
template<>
struct logical_not<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_LOGICAL_NOT_HPP #endif // #ifndef SPROUT_FUNCTIONAL_LOGICAL_NOT_HPP

View file

@ -1,11 +1,13 @@
#ifndef SPROUT_FUNCTIONAL_LOGICAL_OR_HPP #ifndef SPROUT_FUNCTIONAL_LOGICAL_OR_HPP
#define SPROUT_FUNCTIONAL_LOGICAL_OR_HPP #define SPROUT_FUNCTIONAL_LOGICAL_OR_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// 20.8.6 logical operations // 20.8.6 logical operations
template<typename T> template<typename T = void>
struct logical_or { struct logical_or {
public: public:
typedef T first_argument_type; typedef T first_argument_type;
@ -16,6 +18,18 @@ namespace sprout {
return x || y; return x || y;
} }
}; };
template<>
struct logical_or<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_LOGICAL_OR_HPP #endif // #ifndef SPROUT_FUNCTIONAL_LOGICAL_OR_HPP

View file

@ -1,13 +1,15 @@
#ifndef SPROUT_FUNCTIONAL_MINUS_HPP #ifndef SPROUT_FUNCTIONAL_MINUS_HPP
#define SPROUT_FUNCTIONAL_MINUS_HPP #define SPROUT_FUNCTIONAL_MINUS_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk) // Copyright (C) 2011 RiSK (sscrisk)
// 20.8.4 Arithmetic operations // 20.8.4 Arithmetic operations
template<typename T> template<typename T = void>
struct minus { struct minus {
public: public:
typedef T first_argument_type; typedef T first_argument_type;
@ -18,6 +20,18 @@ namespace sprout {
return x - y; return x - y;
} }
}; };
template<>
struct minus<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_MINUS_HPP #endif // #ifndef SPROUT_FUNCTIONAL_MINUS_HPP

View file

@ -1,13 +1,15 @@
#ifndef SPROUT_FUNCTIONAL_MODULUS_HPP #ifndef SPROUT_FUNCTIONAL_MODULUS_HPP
#define SPROUT_FUNCTIONAL_X_HPP #define SPROUT_FUNCTIONAL_X_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk) // Copyright (C) 2011 RiSK (sscrisk)
// 20.8.4 Arithmetic operations // 20.8.4 Arithmetic operations
template<typename T> template<typename T = void>
struct modulus { struct modulus {
public: public:
typedef T first_argument_type; typedef T first_argument_type;
@ -18,6 +20,18 @@ namespace sprout {
return x % y; return x % y;
} }
}; };
template<>
struct modulus<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_MODULUS_HPP #endif // #ifndef SPROUT_FUNCTIONAL_MODULUS_HPP

View file

@ -1,13 +1,15 @@
#ifndef SPROUT_FUNCTIONAL_MULTIPLIES_HPP #ifndef SPROUT_FUNCTIONAL_MULTIPLIES_HPP
#define SPROUT_FUNCTIONAL_MULTIPLIES_HPP #define SPROUT_FUNCTIONAL_MULTIPLIES_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk) // Copyright (C) 2011 RiSK (sscrisk)
// 20.8.4 Arithmetic operations // 20.8.4 Arithmetic operations
template<typename T> template<typename T = void>
struct multiplies { struct multiplies {
public: public:
typedef T first_argument_type; typedef T first_argument_type;
@ -18,6 +20,18 @@ namespace sprout {
return x * y; return x * y;
} }
}; };
template<>
struct multiplies<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_MULTIPLIES_HPP #endif // #ifndef SPROUT_FUNCTIONAL_MULTIPLIES_HPP

View file

@ -1,13 +1,15 @@
#ifndef SPROUT_FUNCTIONAL_NEGATE_HPP #ifndef SPROUT_FUNCTIONAL_NEGATE_HPP
#define SPROUT_FUNCTIONAL_NEGATE_HPP #define SPROUT_FUNCTIONAL_NEGATE_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk) // Copyright (C) 2011 RiSK (sscrisk)
// 20.8.4 Arithmetic operations // 20.8.4 Arithmetic operations
template<typename T> template<typename T = void>
struct negate { struct negate {
public: public:
typedef T argument_type; typedef T argument_type;
@ -17,6 +19,18 @@ namespace sprout {
return -x; return -x;
} }
}; };
template<>
struct negate<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_NEGATE_HPP #endif // #ifndef SPROUT_FUNCTIONAL_NEGATE_HPP

View file

@ -1,13 +1,15 @@
#ifndef SPROUT_FUNCTIONAL_NOT_EQUAL_TO_HPP #ifndef SPROUT_FUNCTIONAL_NOT_EQUAL_TO_HPP
#define SPROUT_FUNCTIONAL_NOT_EQUAL_TO_HPP #define SPROUT_FUNCTIONAL_NOT_EQUAL_TO_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk) // Copyright (C) 2011 RiSK (sscrisk)
// 20.8.5 Comparisons // 20.8.5 Comparisons
template<typename T> template<typename T = void>
struct not_equal_to { struct not_equal_to {
public: public:
typedef T first_argument_type; typedef T first_argument_type;
@ -18,6 +20,18 @@ namespace sprout {
return x != y; return x != y;
} }
}; };
template<>
struct not_equal_to<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_NOT_EQUAL_TO_HPP #endif // #ifndef SPROUT_FUNCTIONAL_NOT_EQUAL_TO_HPP

View file

@ -1,13 +1,15 @@
#ifndef SPROUT_FUNCTIONAL_PLUS_HPP #ifndef SPROUT_FUNCTIONAL_PLUS_HPP
#define SPROUT_FUNCTIONAL_PLUS_HPP #define SPROUT_FUNCTIONAL_PLUS_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk) // Copyright (C) 2011 RiSK (sscrisk)
// 20.8.4 Arithmetic operations // 20.8.4 Arithmetic operations
template<typename T> template<typename T = void>
struct plus { struct plus {
public: public:
typedef T first_argument_type; typedef T first_argument_type;
@ -18,6 +20,18 @@ namespace sprout {
return x + y; return x + y;
} }
}; };
template<>
struct plus<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_PLUS_HPP #endif // #ifndef SPROUT_FUNCTIONAL_PLUS_HPP

View file

@ -7,6 +7,7 @@
#include <sprout/functional/polymorphic/logical.hpp> #include <sprout/functional/polymorphic/logical.hpp>
#include <sprout/functional/polymorphic/bitwise.hpp> #include <sprout/functional/polymorphic/bitwise.hpp>
#include <sprout/functional/polymorphic/inc_dec.hpp> #include <sprout/functional/polymorphic/inc_dec.hpp>
#include <sprout/functional/polymorphic/reference.hpp>
#include <sprout/functional/polymorphic/assignment.hpp> #include <sprout/functional/polymorphic/assignment.hpp>
#include <sprout/functional/polymorphic/members.hpp> #include <sprout/functional/polymorphic/members.hpp>
#include <sprout/functional/polymorphic/various.hpp> #include <sprout/functional/polymorphic/various.hpp>

View file

@ -1,13 +1,15 @@
#ifndef SPROUT_FUNCTIONAL_POSITE_HPP #ifndef SPROUT_FUNCTIONAL_POSITE_HPP
#define SPROUT_FUNCTIONAL_POSITE_HPP #define SPROUT_FUNCTIONAL_POSITE_HPP
#include <utility>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk) // Copyright (C) 2011 RiSK (sscrisk)
// 20.8.4 Arithmetic operations // 20.8.4 Arithmetic operations
template<typename T> template<typename T = void>
struct posite { struct posite {
public: public:
typedef T argument_type; typedef T argument_type;
@ -17,6 +19,18 @@ namespace sprout {
return +x; return +x;
} }
}; };
template<>
struct posite<void> {
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 } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_POSITE_HPP #endif // #ifndef SPROUT_FUNCTIONAL_POSITE_HPP