Added totally ordered.

This commit is contained in:
Takatoshi Kondo 2015-08-30 13:08:00 +09:00
parent 0609347d82
commit df5f84d49d
2 changed files with 10 additions and 2 deletions

View File

@ -37,6 +37,7 @@
#include "msgpack/adaptor/map.hpp"
#include <boost/variant.hpp>
#include <boost/operators.hpp>
namespace msgpack {
@ -70,7 +71,7 @@ typedef boost::variant<
} // namespace detail
struct variant : detail::variant_imp {
struct variant : detail::variant_imp, private boost::totally_ordered<variant> {
typedef detail::variant_imp base;
variant() {}
template <typename T>
@ -115,6 +116,7 @@ inline bool operator==(variant const& lhs, variant const& rhs) {
return static_cast<variant::base const&>(lhs) == static_cast<variant::base const&>(rhs);
}
struct variant_ref;
namespace detail {
@ -139,7 +141,7 @@ typedef boost::variant<
} // namespace detail
struct variant_ref : detail::variant_ref_imp {
struct variant_ref : detail::variant_ref_imp, private boost::totally_ordered<variant_ref> {
typedef detail::variant_ref_imp base;
variant_ref() {}
template <typename T>

View File

@ -87,6 +87,12 @@ TEST(MSGPACK_BOOST, pack_convert_variant_bool)
msgpack::type::variant val2 = ret.get().as<msgpack::type::variant>();
EXPECT_NO_THROW(boost::get<bool>(val2));
EXPECT_TRUE(val1 == val2);
// Tests for totally ordered
EXPECT_FALSE(val1 != val2);
EXPECT_FALSE(val1 < val2);
EXPECT_FALSE(val1 > val2);
EXPECT_TRUE(val1 <= val2);
EXPECT_TRUE(val1 >= val2);
}
TEST(MSGPACK_BOOST, object_variant_bool)