Sprout/sprout/valarray/comparison.hpp

155 lines
7.7 KiB
C++
Raw Normal View History

2016-04-03 04:12:14 +00:00
/*=============================================================================
Copyright (c) 2011-2016 Bolero MURAKAMI
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)
=============================================================================*/
#ifndef SPROUT_VALARRAY_COMPARISON_HPP
#define SPROUT_VALARRAY_COMPARISON_HPP
#include <sprout/config.hpp>
#include <sprout/workaround/std/cstddef.hpp>
#include <sprout/valarray/valarray.hpp>
#include <sprout/algorithm/fixed/transform.hpp>
#include <sprout/functional/equal_to.hpp>
2016-04-03 04:42:12 +00:00
#include <sprout/functional/not_equal_to.hpp>
#include <sprout/functional/greater.hpp>
2016-04-03 04:12:14 +00:00
#include <sprout/functional/less.hpp>
2016-04-03 04:42:12 +00:00
#include <sprout/functional/greater_equal.hpp>
#include <sprout/functional/less_equal.hpp>
2016-04-03 04:12:14 +00:00
#include <sprout/functional/bind2nd.hpp>
#include <sprout/functional/bind1st.hpp>
2016-04-03 09:57:30 +00:00
#include <sprout/sized_pit/sized_pit.hpp>
2016-04-03 04:12:14 +00:00
namespace sprout {
//
// operator==
//
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator==(sprout::valarray<T, N> const& lhs, sprout::valarray<T, N> const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::equal_to<>());
2016-04-03 04:12:14 +00:00
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator==(sprout::valarray<T, N> const& lhs, T const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::equal_to<>(), rhs));
2016-04-03 04:12:14 +00:00
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator==(T const& lhs, sprout::valarray<T, N> const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(rhs.begin(), rhs.end(), sized_pit_type(rhs.size()), sprout::bind1st(sprout::equal_to<>(), lhs));
2016-04-03 04:12:14 +00:00
}
//
// operator!=
//
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator!=(sprout::valarray<T, N> const& lhs, sprout::valarray<T, N> const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::not_equal_to<>());
2016-04-03 04:12:14 +00:00
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator!=(sprout::valarray<T, N> const& lhs, T const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::not_equal_to<>(), rhs));
2016-04-03 04:12:14 +00:00
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator!=(T const& lhs, sprout::valarray<T, N> const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(rhs.begin(), rhs.end(), sized_pit_type(rhs.size()), sprout::bind1st(sprout::not_equal_to<>(), lhs));
2016-04-03 04:12:14 +00:00
}
//
// operator<
//
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator<(sprout::valarray<T, N> const& lhs, sprout::valarray<T, N> const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::less<>());
2016-04-03 04:12:14 +00:00
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator<(sprout::valarray<T, N> const& lhs, T const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::less<>(), rhs));
2016-04-03 04:12:14 +00:00
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator<(T const& lhs, sprout::valarray<T, N> const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(rhs.begin(), rhs.end(), sized_pit_type(rhs.size()), sprout::bind1st(sprout::less<>(), lhs));
2016-04-03 04:12:14 +00:00
}
//
// operator>
//
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator>(sprout::valarray<T, N> const& lhs, sprout::valarray<T, N> const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::greater<>());
2016-04-03 04:12:14 +00:00
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator>(sprout::valarray<T, N> const& lhs, T const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::greater<>(), rhs));
2016-04-03 04:12:14 +00:00
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator>(T const& lhs, sprout::valarray<T, N> const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(rhs.begin(), rhs.end(), sized_pit_type(rhs.size()), sprout::bind1st(sprout::greater<>(), lhs));
2016-04-03 04:12:14 +00:00
}
//
// operator<=
//
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator<=(sprout::valarray<T, N> const& lhs, sprout::valarray<T, N> const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::less_equal<>());
2016-04-03 04:12:14 +00:00
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator<=(sprout::valarray<T, N> const& lhs, T const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::less_equal<>(), rhs));
2016-04-03 04:12:14 +00:00
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator<=(T const& lhs, sprout::valarray<T, N> const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(rhs.begin(), rhs.end(), sized_pit_type(rhs.size()), sprout::bind1st(sprout::less_equal<>(), lhs));
2016-04-03 04:12:14 +00:00
}
//
// operator>=
//
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator>=(sprout::valarray<T, N> const& lhs, sprout::valarray<T, N> const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::greater_equal<>());
2016-04-03 04:12:14 +00:00
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator>=(sprout::valarray<T, N> const& lhs, T const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::greater_equal<>(), rhs));
2016-04-03 04:12:14 +00:00
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator>=(T const& lhs, sprout::valarray<T, N> const& rhs) {
2016-04-03 05:29:33 +00:00
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(rhs.begin(), rhs.end(), sized_pit_type(rhs.size()), sprout::bind1st(sprout::greater_equal<>(), lhs));
2016-04-03 04:12:14 +00:00
}
} // namespace sprout
#endif // #ifndef SPROUT_VALARRAY_COMPARISON_HPP