2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2014-01-08 07:48:12 +00:00
|
|
|
Copyright (c) 2011-2014 Bolero MURAKAMI
|
2013-08-08 09:54:33 +00:00
|
|
|
https://github.com/bolero-MURAKAMI/Sprout
|
|
|
|
|
|
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
=============================================================================*/
|
2012-04-09 16:38:55 +00:00
|
|
|
#ifndef SPROUT_FUNCTIONAL_NOT2_HPP
|
|
|
|
#define SPROUT_FUNCTIONAL_NOT2_HPP
|
|
|
|
|
|
|
|
#include <functional>
|
2013-09-04 03:07:54 +00:00
|
|
|
#include <utility>
|
2012-04-09 16:38:55 +00:00
|
|
|
#include <sprout/config.hpp>
|
2013-09-04 03:07:54 +00:00
|
|
|
#include <sprout/functional/type_traits/is_strict_function.hpp>
|
|
|
|
#include <sprout/utility/forward.hpp>
|
2012-04-09 16:38:55 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
2013-09-04 03:07:54 +00:00
|
|
|
namespace detail {
|
|
|
|
template<typename Predicate, bool IsStrict = sprout::is_strict_binary_function<Predicate>::value>
|
|
|
|
class binary_negate_impl;
|
|
|
|
|
|
|
|
template<typename Predicate>
|
|
|
|
class binary_negate_impl<Predicate, true> {
|
|
|
|
public:
|
|
|
|
typedef typename Predicate::first_argument_type first_argument_type;
|
|
|
|
typedef typename Predicate::second_argument_type second_argument_type;
|
|
|
|
typedef bool result_type;
|
|
|
|
protected:
|
|
|
|
Predicate fn;
|
|
|
|
public:
|
|
|
|
explicit SPROUT_CONSTEXPR binary_negate_impl(Predicate const& pred)
|
|
|
|
: fn(pred)
|
|
|
|
{}
|
|
|
|
SPROUT_CONSTEXPR bool operator()(typename Predicate::first_argument_type const& x, typename Predicate::second_argument_type const& y) const {
|
|
|
|
return !fn(x, y);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename Predicate>
|
|
|
|
class binary_negate_impl<Predicate, false> {
|
|
|
|
protected:
|
|
|
|
Predicate fn;
|
|
|
|
public:
|
|
|
|
explicit SPROUT_CONSTEXPR binary_negate_impl(Predicate const& pred)
|
|
|
|
: fn(pred)
|
|
|
|
{}
|
|
|
|
template<typename T, typename U>
|
|
|
|
SPROUT_CONSTEXPR decltype(!std::declval<Predicate const&>()(std::declval<T>(), std::declval<U>()))
|
|
|
|
operator()(T&& x, U&& y) const {
|
|
|
|
return !fn(sprout::forward<T>(x), sprout::forward<U>(y));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace detail
|
|
|
|
|
2012-04-09 16:38:55 +00:00
|
|
|
// 20.8.8 negators
|
|
|
|
template<typename Predicate>
|
2013-09-04 03:07:54 +00:00
|
|
|
class binary_negate
|
|
|
|
: public sprout::detail::binary_negate_impl<Predicate>
|
|
|
|
{
|
2012-04-09 16:38:55 +00:00
|
|
|
public:
|
|
|
|
explicit SPROUT_CONSTEXPR binary_negate(Predicate const& pred)
|
2013-09-04 03:07:54 +00:00
|
|
|
: sprout::detail::binary_negate_impl<Predicate>(pred)
|
2012-04-09 16:38:55 +00:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename Predicate>
|
2012-10-06 04:53:07 +00:00
|
|
|
inline SPROUT_CONSTEXPR sprout::binary_negate<Predicate>
|
|
|
|
not2(Predicate const& pred) {
|
2012-04-09 16:38:55 +00:00
|
|
|
return sprout::binary_negate<Predicate>(pred);
|
|
|
|
}
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_FUNCTIONAL_NOT2_HPP
|