Created
April 14, 2021 07:40
-
-
Save tomlankhorst/e4201eb36c2e75b3f89a1fde5f24d518 to your computer and use it in GitHub Desktop.
Decay optional type
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
template<typename T> | |
struct decay_optional { | |
using type = T; | |
}; | |
template<typename T> | |
struct decay_optional<std::optional<T>> { | |
using type = T; | |
}; | |
template<typename T> | |
struct decay_optional<boost::optional<T>> { | |
using type = T; | |
}; | |
template<typename T> | |
using decay_optional_t = typename decay_optional<T>::type; | |
static_assert(std::is_same_v<decay_optional_t<std::byte>, std::byte>); | |
static_assert(std::is_same_v<decay_optional_t<std::optional<std::byte>>, std::byte>); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment