[c++] Broken move .ctor of bonded<Reader&>

When moving a bonded<> backed by a reference to a reader, the bonded<>
move ctor wasn't building with Clang and newer versions of MSVC. This
fixes that error by not calling std::move on the reference.
This commit is contained in:
Ara Ayvazyan 2018-03-02 17:23:39 -08:00 коммит произвёл Christopher Warrington
Родитель 391a4c9093
Коммит 5131a95042
3 изменённых файлов: 21 добавлений и 2 удалений

Просмотреть файл

@ -59,6 +59,7 @@ different versioning scheme, following the Haskell community's
* Fixed a race condition when `bond::ext::gRPC::io_manager::shutdown` and
`bond::ext::gRPC::io_manager::wait` are called concurrently.
* Fixed a race condition during `bond::ext::gRPC::unary_call` destruction.
* Fixed the broken move constructor of `bond::bonded<T, Reader&>`.
### C# ###

Просмотреть файл

@ -26,6 +26,24 @@ template <typename Protocols, typename Transform, typename T, typename Reader>
typename boost::enable_if<need_double_pass<Transform>, bool>::type inline
ApplyTransform(const Transform& transform, const bonded<T, Reader>& bonded);
// Helper function move_data for dealing with [not] moving a Reader& in bonded<T, Reader&>
template <typename T, typename U>
typename boost::enable_if<std::is_reference<T>, T>::type
inline move_data(U& data)
{
BOOST_STATIC_ASSERT(std::is_same<T, U&>::value);
return data;
}
template <typename T, typename U>
typename boost::disable_if<std::is_reference<T>, T&&>::type
inline move_data(U& data)
{
BOOST_STATIC_ASSERT(std::is_same<T, U>::value);
return std::move(data);
}
} // namespace detail
@ -61,7 +79,7 @@ public:
bonded(bonded&& bonded) BOND_NOEXCEPT_IF(
std::is_nothrow_move_constructible<Reader>::value
&& std::is_nothrow_move_constructible<RuntimeSchema>::value)
: _data(std::move(bonded._data)),
: _data(detail::move_data<Reader>(bonded._data)),
_schema(std::move(bonded._schema)),
_skip(std::move(bonded._skip)),
_base(std::move(bonded._base))

Просмотреть файл

@ -52,7 +52,7 @@ public:
bonded(bonded&& other) BOND_NOEXCEPT_IF(
std::is_nothrow_move_constructible<Reader>::value
&& std::is_nothrow_move_constructible<RuntimeSchema>::value)
: _data(std::move(other._data)),
: _data(detail::move_data<Reader>(other._data)),
_schema(std::move(other._schema)),
_skip(std::move(other._skip)),
_base(std::move(other._base))