BAN: Add Forward()
This commit is contained in:
		
							parent
							
								
									b9a4530e54
								
							
						
					
					
						commit
						124afbecaa
					
				|  | @ -3,17 +3,36 @@ | |||
| namespace BAN | ||||
| { | ||||
| 
 | ||||
| 	template <class T> | ||||
| 	struct RemoveReference { typedef T type; }; | ||||
| 	template<typename T> | ||||
| 	struct RemoveReference { using type = T; }; | ||||
| 	template<typename T> | ||||
| 	struct RemoveReference<T&> { using type =  T; }; | ||||
| 	template<typename T> | ||||
| 	struct RemoveReference<T&&> { using type = T; }; | ||||
| 
 | ||||
| 	template <class T> | ||||
| 	struct RemoveReference<T&> { typedef T type; }; | ||||
| 	template<typename T> | ||||
| 	struct IsLValueReference { static constexpr bool value = false; }; | ||||
| 	template<typename T> | ||||
| 	struct IsLValueReference<T&> { static constexpr bool value = true; }; | ||||
| 
 | ||||
| 	template <class T> | ||||
| 	struct RemoveReference<T&&> { typedef T type; }; | ||||
| 
 | ||||
| 	template<class T> | ||||
| 	typename RemoveReference<T>::type&& | ||||
| 	Move( T&& Arg ) { return (typename RemoveReference<T>::type&&)Arg; } | ||||
| 	template<typename T> | ||||
| 	constexpr typename RemoveReference<T>::type&& Move(T&& arg) | ||||
| 	{ | ||||
| 		return static_cast<typename RemoveReference<T>::type&&>(arg); | ||||
| 	} | ||||
| 
 | ||||
| 	template<typename T> | ||||
| 	constexpr T&& Forward(typename RemoveReference<T>::type& arg) | ||||
| 	{ | ||||
| 		return static_cast<T&&>(arg); | ||||
| 	} | ||||
| 
 | ||||
| 	template<typename T> | ||||
| 	constexpr T&& Forward(typename RemoveReference<T>::type&& arg) | ||||
| 	{ | ||||
| 		static_assert(!IsLValueReference<T>::value); | ||||
| 		return static_cast<T&&>(arg); | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
		Loading…
	
		Reference in New Issue