view gcc/testsuite/g++.dg/cpp1y/udlit-char-template-sfinae.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
line wrap: on
line source

// { dg-do run { target c++14 } }

#include <cassert>

template<bool, typename _Tp = void>struct enable_if {};
template<typename _Tp> struct enable_if<true, _Tp> { typedef _Tp type; };


template<typename CharT, CharT... String>
typename enable_if<sizeof...(String) == 6, int>::type operator"" _script () {
  return 5;
}

template<typename CharT, CharT... String>
typename enable_if<sizeof...(String) == 3, int>::type operator"" _script () {
  return 3;
}

template<typename CharT, CharT... String>
typename enable_if<sizeof...(String) != 3 && sizeof...(String) != 6, int>::type operator"" _script () {
  return 1;
}

int main ()
{
  assert ("hello!"_script == 5);
  assert (u8"hi!"_script == 3);
  assert ("hey!"_script == 1);
}