Skip to content

Commit a3cd1a2

Browse files
authored
fix(bytes): replace std::forward<D>(d) with std::move(d) in move constructors (#776)
MSVC 19.44 (VS 2022 17.14) rejects std::forward<D>(d) when D is deduced as decltype(d) — a local lambda type (always non-reference). The compiler cannot convert the lvalue lambda to D&&, yielding C2665/C3536. std::move(d) is the correct form here: D is never a reference type in these constructors so std::forward<D> is semantically equivalent to std::move, but newer MSVC enforces the distinction. Affects three Bytes constructors: - Bytes(std::vector<uint8_t, Allocator>&&) - Bytes(std::string&&) - Bytes(uint8_t*, size_t, Deleter) Fixes ROS 2 buildfarm Windows build failure: https://ci.ros2.org/job/ci_windows/27547/
1 parent 67f6728 commit a3cd1a2

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

include/zenoh/api/bytes.hxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class Bytes : public Owned<::z_owned_bytes_t> {
6868
using D = decltype(d);
6969
using Dval = std::remove_reference_t<D>;
7070
using DroppableType = typename detail::closures::Droppable<Dval>;
71-
auto drop = DroppableType::into_context(std::forward<D>(d));
71+
auto drop = DroppableType::into_context(std::move(d));
7272
::z_bytes_from_buf(interop::as_owned_c_ptr(*this), ptr->data(), ptr->size(),
7373
detail::closures::_zenoh_drop_with_context, drop);
7474
}
@@ -93,7 +93,7 @@ class Bytes : public Owned<::z_owned_bytes_t> {
9393
using D = decltype(d);
9494
using Dval = std::remove_reference_t<D>;
9595
using DroppableType = typename detail::closures::Droppable<Dval>;
96-
auto drop = DroppableType::into_context(std::forward<D>(d));
96+
auto drop = DroppableType::into_context(std::move(d));
9797
::z_bytes_from_buf(interop::as_owned_c_ptr(*this), reinterpret_cast<uint8_t*>(ptr->data()), ptr->size(),
9898
detail::closures::_zenoh_drop_with_context, drop);
9999
}
@@ -112,7 +112,7 @@ class Bytes : public Owned<::z_owned_bytes_t> {
112112
using D = decltype(d);
113113
using Dval = std::remove_reference_t<D>;
114114
using DroppableType = typename detail::closures::Droppable<Dval>;
115-
auto drop = DroppableType::into_context(std::forward<D>(d));
115+
auto drop = DroppableType::into_context(std::move(d));
116116
::z_bytes_from_buf(interop::as_owned_c_ptr(*this), ptr, len, detail::closures::_zenoh_drop_with_context, drop);
117117
}
118118

0 commit comments

Comments
 (0)