mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-05-29 07:25:55 +02:00
Added * and -> operators to object_handle
This commit is contained in:
parent
b02c6beb4d
commit
d452625ed1
@ -70,6 +70,18 @@ public:
|
|||||||
const msgpack::object& get() const
|
const msgpack::object& get() const
|
||||||
{ return m_obj; }
|
{ return m_obj; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return object (to mimic smart pointers).
|
||||||
|
*/
|
||||||
|
const msgpack::object& operator*() const
|
||||||
|
{ return get(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the address of the object (to mimic smart pointers).
|
||||||
|
*/
|
||||||
|
const msgpack::object* operator->() const
|
||||||
|
{ return &get(); }
|
||||||
|
|
||||||
/// Get unique_ptr reference of zone.
|
/// Get unique_ptr reference of zone.
|
||||||
/**
|
/**
|
||||||
* @return unique_ptr reference of zone
|
* @return unique_ptr reference of zone
|
||||||
|
@ -445,3 +445,12 @@ TEST(object, pack_double)
|
|||||||
EXPECT_EQ(static_cast<size_t>(9), ss1.str().size());
|
EXPECT_EQ(static_cast<size_t>(9), ss1.str().size());
|
||||||
EXPECT_EQ(ss1.str(), ss2.str());
|
EXPECT_EQ(ss1.str(), ss2.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(object, handle_operators)
|
||||||
|
{
|
||||||
|
int i = 1;
|
||||||
|
msgpack::object obj(i);
|
||||||
|
msgpack::object_handle oh = msgpack::clone(obj);
|
||||||
|
EXPECT_EQ(oh.get(), *oh);
|
||||||
|
EXPECT_EQ(oh->as<int>(), oh.get().as<int>());
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user