move.hpp 609 B

123456789101112131415161718192021222324252627
  1. // Copyright Takatoshi Kondo 2019
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. #if !defined(MQTT_MOVE_HPP)
  7. #define MQTT_MOVE_HPP
  8. #include <utility>
  9. #include <type_traits>
  10. #include <mqtt/namespace.hpp>
  11. namespace MQTT_NS {
  12. template <typename T>
  13. constexpr
  14. typename std::remove_reference_t<T>&&
  15. force_move(T&& t) {
  16. static_assert(!std::is_const<std::remove_reference_t<T>>::value, "T is const. Fallback to copy.");
  17. return std::move(t);
  18. }
  19. } // namespace MQTT_NS
  20. #endif // MQTT_MOVE_HPP