-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 `<type_traits>` header. | ||
/// @tparam T | ||
template <typename T> | ||
struct RemoveReference | ||
{ | ||
/// @brief Type without references. | ||
using Type = T; | ||
}; | ||
|
||
template <typename T> | ||
struct RemoveReference<T&> | ||
{ | ||
using Type = T; | ||
}; | ||
|
||
template <typename T> | ||
struct RemoveReference<T&&> | ||
{ | ||
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 | ||
/// `<utility>` header. | ||
/// @tparam T Value type. | ||
/// @param value Value to move. | ||
/// @return Moved value. | ||
/// @ingroup core-memory | ||
template <typename T> | ||
typename RemoveReference<T>::Type&& move(T&& value) | ||
{ | ||
return static_cast<typename RemoveReference<T>::Type&&>(value); | ||
} | ||
} // namespace cubos::core::memory |