/*============================================================================= Copyright (c) 2011-2017 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_STRING_NPOS_HPP #define SPROUT_STRING_NPOS_HPP #include #include #include #include namespace sprout { // // npos_t // npos // struct npos_t { public: template::value>::type = sprout::enabler> struct get : public sprout::integral_constant {}; public: template::value>::type = sprout::enabler> SPROUT_CONSTEXPR operator UIntType() const { return UIntType(-1); } }; namespace { SPROUT_STATIC_CONSTEXPR sprout::npos_t npos = {}; } // anonymous-namespace // // operator== // operator!= // operator< // operator> // operator<= // operator>= // template::value>::type = sprout::enabler> inline SPROUT_CONSTEXPR bool operator==(UIntType const& lhs, sprout::npos_t rhs) { return lhs == UIntType(rhs); } template::value>::type = sprout::enabler> inline SPROUT_CONSTEXPR bool operator==(sprout::npos_t lhs, UIntType const& rhs) { return rhs == lhs; } inline SPROUT_CONSTEXPR bool operator==(sprout::npos_t, sprout::npos_t) { return true; } template::value>::type = sprout::enabler> inline SPROUT_CONSTEXPR bool operator!=(UIntType const& lhs, sprout::npos_t rhs) { return !(lhs == rhs); } template::value>::type = sprout::enabler> inline SPROUT_CONSTEXPR bool operator!=(sprout::npos_t lhs, UIntType const& rhs) { return !(lhs == rhs); } inline SPROUT_CONSTEXPR bool operator!=(sprout::npos_t lhs, sprout::npos_t rhs) { return !(lhs == rhs); } template::value>::type = sprout::enabler> inline SPROUT_CONSTEXPR bool operator<(UIntType const& lhs, sprout::npos_t rhs) { return lhs < UIntType(rhs); } template::value>::type = sprout::enabler> inline SPROUT_CONSTEXPR bool operator<(sprout::npos_t lhs, UIntType const& rhs) { return rhs == lhs; } inline SPROUT_CONSTEXPR bool operator<(sprout::npos_t, sprout::npos_t) { return false; } template::value>::type = sprout::enabler> inline SPROUT_CONSTEXPR bool operator>(UIntType const& lhs, sprout::npos_t rhs) { return rhs < lhs; } template::value>::type = sprout::enabler> inline SPROUT_CONSTEXPR bool operator>(sprout::npos_t lhs, UIntType const& rhs) { return rhs < lhs; } inline SPROUT_CONSTEXPR bool operator>(sprout::npos_t lhs, sprout::npos_t rhs) { return rhs < lhs; } template::value>::type = sprout::enabler> inline SPROUT_CONSTEXPR bool operator<=(UIntType const& lhs, sprout::npos_t rhs) { return !(rhs < lhs); } template::value>::type = sprout::enabler> inline SPROUT_CONSTEXPR bool operator<=(sprout::npos_t lhs, UIntType const& rhs) { return !(rhs < lhs); } inline SPROUT_CONSTEXPR bool operator<=(sprout::npos_t lhs, sprout::npos_t rhs) { return !(rhs < lhs); } template::value>::type = sprout::enabler> inline SPROUT_CONSTEXPR bool operator>=(UIntType const& lhs, sprout::npos_t rhs) { return !(lhs < rhs); } template::value>::type = sprout::enabler> inline SPROUT_CONSTEXPR bool operator>=(sprout::npos_t lhs, UIntType const& rhs) { return !(lhs < rhs); } inline SPROUT_CONSTEXPR bool operator>=(sprout::npos_t lhs, sprout::npos_t rhs) { return !(lhs < rhs); } } // namespace sprout #endif // #ifndef SPROUT_STRING_NPOS_HPP