Created
November 21, 2018 12:39
-
-
Save DasNaCl/0a1fefa63d7beb45dd992b59a37f6b59 to your computer and use it in GitHub Desktop.
This file contains 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> | |
template<int> struct int_constant {}; | |
template<char> struct char_constant {}; | |
inline constexpr struct ubiq | |
{ | |
template<class T> | |
constexpr operator T() const noexcept | |
{ return T{}; } | |
} ubiq_; | |
template<auto X, template<auto> class T> | |
auto match(T<X>) -> decltype(X); | |
template<template<auto> class Trait> | |
using nttp_t = decltype(match(Trait<ubiq_>{})); | |
static_assert(std::is_same_v<decltype(match(int_constant<42>{})), int>); | |
static_assert(std::is_same_v<nttp_t<int_constant>, int>); | |
static_assert(std::is_same_v<nttp_t<char_constant>, char>); | |
int main(){} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment