mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-06-05 14:10:51 +02:00
Added totally ordered.
This commit is contained in:
parent
0609347d82
commit
df5f84d49d
@ -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>
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user