-
Notifications
You must be signed in to change notification settings - Fork 3
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
4 changed files
with
33 additions
and
6 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
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,26 @@ | ||
// | ||
// Created by yonggyulee on 2024. 8. 10. | ||
// | ||
|
||
#ifndef PREVIEW_UTILITY_FORWARD_LIKE_H_ | ||
#define PREVIEW_UTILITY_FORWARD_LIKE_H_ | ||
|
||
#include <type_traits> | ||
|
||
#include "preview/__type_traits/copy_cvref.h" | ||
|
||
namespace preview { | ||
|
||
template<typename T, typename U> | ||
constexpr auto&& forward_like(U&& x) noexcept { | ||
using CU = copy_const_t<std::remove_reference_t<T>, std::remove_reference_t<U>>; | ||
using RU = std::conditional_t<std::is_rvalue_reference<T>::value, std::remove_reference_t<CU>&&, CU&>; | ||
return static_cast<RU>(x); | ||
} | ||
|
||
template<typename T, typename U> | ||
using forward_like_t = decltype(preview::forward_like<T>(std::declval<U>())); | ||
|
||
} // namespace preview | ||
|
||
#endif // PREVIEW_UTILITY_FORWARD_LIKE_H_ |
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