Skip to content

Instantly share code, notes, and snippets.

@BillyDonahue
Last active October 31, 2020 21:11
Show Gist options
  • Save BillyDonahue/c3aaf3095e8c502323ca9c4220f192fd to your computer and use it in GitHub Desktop.
Save BillyDonahue/c3aaf3095e8c502323ca9c4220f192fd to your computer and use it in GitHub Desktop.
msvc bug: expr sfinae on private
#include <type_traits>
template <typename T, typename=void> struct Direct : std::false_type {};
template <typename T> struct Direct<T, std::void_t<decltype(std::declval<T>().f())>> : std::true_type {};
template <typename T> using Op = decltype(std::declval<T>().f());
template <typename T, typename=void> struct ViaAlias : std::false_type {};
template <typename T> struct ViaAlias<T, std::void_t<Op<T>>> : std::true_type {};
class X { void f(); };
static_assert(!Direct<X>::value,"Direct<X>"); // PASSES
static_assert(!ViaAlias<X>::value,"ViaAlias<X>"); // FAILS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment