diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 8f2582980..45c603cb0 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -91,6 +91,7 @@ set(CUBOS_CORE_INCLUDE "include/cubos/core/settings.hpp" "include/cubos/core/thread_pool.hpp" + "include/cubos/core/memory/move.hpp" "include/cubos/core/memory/stream.hpp" "include/cubos/core/memory/standard_stream.hpp" "include/cubos/core/memory/buffer_stream.hpp" diff --git a/core/include/cubos/core/memory/move.hpp b/core/include/cubos/core/memory/move.hpp new file mode 100644 index 000000000..ec16408ca --- /dev/null +++ b/core/include/cubos/core/memory/move.hpp @@ -0,0 +1,44 @@ +/// @file +/// @brief Function @ref cubos::core::memory::move. +/// @ingroup core-memory + +#pragma once + +namespace cubos::core::memory +{ + /// @brief Provides a type which is the same as the given type, but without any references. + /// @note This is a replacement for `std::remove_reference`, which allows us to avoid including + /// the entire `` header. + /// @tparam T + template + struct RemoveReference + { + /// @brief Type without references. + using Type = T; + }; + + template + struct RemoveReference + { + using Type = T; + }; + + template + struct RemoveReference + { + using Type = T; + }; + + /// @brief Returns an R-value reference to the given value + /// @note This is a replacement for `std::move`, which allows us to avoid including the entire + /// `` header. + /// @tparam T Value type. + /// @param value Value to move. + /// @return Moved value. + /// @ingroup core-memory + template + typename RemoveReference::Type&& move(T&& value) + { + return static_cast::Type&&>(value); + } +} // namespace cubos::core::memory