mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-18 03:29:49 +02:00
Support to-object conversions for std::reference_wrapper<const T>.
Previously the conversion would fail because struct object is not generally provided for the const version of the type, but because the wrapper would pass down the type unchanged, it would look for exactly that missing template specialization unsuccessfully. This is specifically an issue for std::reference_wrapper because std::cref() returns an std::reference_wrapper<const T>.
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
@@ -53,14 +54,14 @@ struct pack<std::reference_wrapper<T>> {
|
||||
template <typename T>
|
||||
struct object<std::reference_wrapper<T> > {
|
||||
void operator()(msgpack::object& o, const std::reference_wrapper<T>& v) const {
|
||||
msgpack::adaptor::object<T>()(o, v.get());
|
||||
msgpack::adaptor::object<typename std::remove_const<T>::type>()(o, v.get());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct object_with_zone<std::reference_wrapper<T>> {
|
||||
void operator()(msgpack::object::with_zone& o, const std::reference_wrapper<T>& v) const {
|
||||
msgpack::adaptor::object_with_zone<T>()(o, v.get());
|
||||
msgpack::adaptor::object_with_zone<typename std::remove_const<T>::type>()(o, v.get());
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user