Fix compiler warning C4822

This commit is contained in:
nsubiron 2019-05-07 11:59:45 +02:00
parent 9e2ea00820
commit 423508e8ba
1 changed files with 15 additions and 8 deletions

View File

@ -10,6 +10,20 @@
#include <utility>
namespace carla {
namespace detail {
template <typename FunctorT>
struct MoveWrapper : FunctorT {
MoveWrapper(FunctorT &&f) : FunctorT(std::move(f)) {}
MoveWrapper(MoveWrapper &&) = default;
MoveWrapper& operator=(MoveWrapper &&) = default;
MoveWrapper(const MoveWrapper &);
MoveWrapper& operator=(const MoveWrapper &);
};
} // namespace detail
/// Hack to trick asio into accepting move-only handlers, if the handler were
/// actually copied it would result in a link error.
@ -18,14 +32,7 @@ namespace carla {
template <typename FunctorT>
auto MoveHandler(FunctorT &&func) {
using F = typename std::decay<FunctorT>::type;
struct MoveWrapper : F {
MoveWrapper(F&& f) : F(std::move(f)) {}
MoveWrapper(MoveWrapper&&) = default;
MoveWrapper& operator=(MoveWrapper&&) = default;
MoveWrapper(const MoveWrapper&);
MoveWrapper& operator=(const MoveWrapper&);
};
return MoveWrapper{std::move(func)};
return detail::MoveWrapper<F>{std::move(func)};
}
} // namespace carla