mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-14 15:05:37 +02:00
lang/c/msgpack: C++ binding: reexamined global operators
git-svn-id: file:///Users/frsyuki/project/msgpack-git/svn/x@72 5a5092ae-2292-43ba-b2d5-dcab9c1a2731
This commit is contained in:
@@ -22,45 +22,43 @@
|
||||
#include <vector>
|
||||
|
||||
namespace msgpack {
|
||||
namespace type {
|
||||
|
||||
|
||||
// FIXME check overflow, underflow
|
||||
|
||||
|
||||
inline float& operator<< (float& v, object o)
|
||||
inline float& operator>> (object o, float& v)
|
||||
{
|
||||
if(o.type != DOUBLE) { throw type_error(); }
|
||||
if(o.type != type::DOUBLE) { throw type_error(); }
|
||||
v = o.via.dec;
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
template <typename Stream>
|
||||
inline const float& operator>> (const float& v, packer<Stream> o)
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const float& v)
|
||||
{
|
||||
o.pack_float(v);
|
||||
return v;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
inline double& operator<< (double& v, object o)
|
||||
inline double& operator>> (object o, double& v)
|
||||
{
|
||||
if(o.type != DOUBLE) { throw type_error(); }
|
||||
if(o.type != type::DOUBLE) { throw type_error(); }
|
||||
v = o.via.dec;
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
template <typename Stream>
|
||||
inline const double& operator>> (const double& v, packer<Stream> o)
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const double& v)
|
||||
{
|
||||
o.pack_double(v);
|
||||
return v;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
} // namespace type
|
||||
} // namespace msgpack
|
||||
|
||||
#endif /* msgpack/type/float.hpp */
|
||||
|
Reference in New Issue
Block a user