Created
April 25, 2015 20:37
-
-
Save Naios/54ccbd129839f460a614 to your computer and use it in GitHub Desktop.
Archive of code pieces
This file contains hidden or 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
//! Returns an optional created from the given value. | |
template <typename T> | |
inline typename std::enable_if<!std::is_rvalue_reference<T>::value, Optional<T>>::type | |
make_optional(typename std::decay<T>::type const& value) | |
{ | |
return Optional<T>(value); | |
} | |
//! Returns an optional created from the given moved value. | |
template <typename T> | |
inline typename std::enable_if<std::is_rvalue_reference<T>::value, Optional<T>>::type | |
make_optional(typename std::decay<T>::type&& value) | |
{ | |
return Optional<T>(std::forward<typename std::decay<T>::type>(value)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment