// Copyright (c) 2019 Computer Vision Center (CVC) at the Universitat Autonoma // de Barcelona (UAB). // // This work is licensed under the terms of the MIT license. // For a copy, see . #pragma once #include #include namespace carla { namespace detail { template 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. /// /// @see https://stackoverflow.com/a/22891509. template auto MoveHandler(FunctorT &&func) { using F = typename std::decay::type; return detail::MoveWrapper{std::move(func)}; } } // namespace carla