Skip to content

Instantly share code, notes, and snippets.

@Redchards
Created February 19, 2016 23:00
Show Gist options
  • Select an option

  • Save Redchards/0ddd33f9eaa109e39eaa to your computer and use it in GitHub Desktop.

Select an option

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.
#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