Created
February 19, 2016 23:00
-
-
Save Redchards/0ddd33f9eaa109e39eaa to your computer and use it in GitHub Desktop.
Simple metafunction to check if an object is of literal type. Used as an example to show how useful the SFINAE is.
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
| #include<type_traits> | |
| // I generally use this metafunction to show how useful the SFINAE is in metaprogramming. | |
| namespace | |
| { | |
| template<class T> | |
| struct constexpr_validator | |
| { | |
| static constexpr T m_{}; | |
| }; | |
| template<class T> | |
| constexpr std::integral_constant<bool, (T{}, 1)> test_constexpr(int); | |
| template<class T> | |
| constexpr std::false_type test_constexpr(...); | |
| } | |
| constexpr optional(optional&& other) noexcept = delete; | |
| constexpr optional(T&& other) noexcept = delete; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment