cpp: explicit object(const T& v)

This commit is contained in:
frsyuki 2010-04-25 02:30:53 +09:00
parent 05e28752f1
commit 7d945d3c8e
2 changed files with 35 additions and 5 deletions

View file

@ -90,8 +90,10 @@ struct object {
object();
object(msgpack_object o);
template <typename T>
object(const T& v);
explicit object(const T& v);
template <typename T>
object(const T& v, zone* z);
@ -131,6 +133,15 @@ bool operator!=(const object x, const object y);
template <typename T>
bool operator==(const object x, const T& y);
template <typename T>
bool operator==(const T& y, const object x);
template <typename T>
bool operator!=(const object x, const T& y);
template <typename T>
bool operator!=(const T& y, const object x);
std::ostream& operator<< (std::ostream& s, const object o);
@ -217,9 +228,6 @@ void operator<< (object::with_zone& o, const T& v)
}
inline bool operator!=(const object x, const object y)
{ return !(x == y); }
template <typename T>
inline bool operator==(const object x, const T& y)
try {
@ -228,6 +236,21 @@ try {
return false;
}
inline bool operator!=(const object x, const object y)
{ return !(x == y); }
template <typename T>
inline bool operator==(const T& y, const object x)
{ return x == y; }
template <typename T>
inline bool operator!=(const object x, const T& y)
{ return !(x == y); }
template <typename T>
inline bool operator!=(const T& y, const object x)
{ return x != y; }
inline object::implicit_type object::convert() const
{
@ -277,6 +300,12 @@ object::object(const T& v, zone* z)
}
inline object::object(msgpack_object o)
{
// FIXME beter way?
::memcpy(this, &o, sizeof(o));
}
inline object::operator msgpack_object()
{
// FIXME beter way?

View file

@ -28,7 +28,8 @@
{ \
msgpack::type::make_define(__VA_ARGS__).msgpack_unpack(o); \
}\
void msgpack_object(msgpack::object* o, msgpack::zone* z) const \
template <typename MSGPACK_OBJECT> \
void msgpack_object(MSGPACK_OBJECT* o, msgpack::zone* z) const \
{ \
msgpack::type::make_define(__VA_ARGS__).msgpack_object(o, z); \
}