Skip to content

Instantly share code, notes, and snippets.

@Alpha255
Created March 30, 2020 08:15
Show Gist options
  • Select an option

  • Save Alpha255/1aeba4928267c4660ac49e9e312b60d9 to your computer and use it in GitHub Desktop.

Select an option

Save Alpha255/1aeba4928267c4660ac49e9e312b60d9 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <type_traits>
template <typename T>
std::true_type test_is_class_or_union(int T::*);
template <typename T>
std::false_type test_is_class_or_union(...);
template <typename T>
struct is_class_or_union : decltype(test_is_class_or_union<T>(nullptr)) {};
template <typename T>
struct is_enum : public std::integral_constant<bool,
!std::is_void<T>::value &&
!std::is_null_pointer<T>::value &&
!std::is_integral<T>::value &&
!std::is_floating_point<T>::value &&
!std::is_array<T>::value &&
!std::is_function<T>::value &&
!std::is_pointer<T>::value &&
!std::is_reference<T>::value &&
!std::is_member_pointer<T>::value &&
!::is_class_or_union<T>::value>
{};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment