Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/cpp0x/constexpr-decltype3.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 // PR c++/88815 | |
2 // { dg-do compile { target c++11 } } | |
3 | |
4 struct true_type { | |
5 constexpr operator bool() const { return true; } | |
6 }; | |
7 | |
8 struct false_type { | |
9 constexpr operator bool() const { return false; } | |
10 }; | |
11 | |
12 template<int (*p)()> | |
13 true_type is_constexpr_impl(decltype(int{(p(), 0U)})); | |
14 | |
15 template<int (*p)()> | |
16 false_type is_constexpr_impl(...); | |
17 | |
18 template<int (*p)()> | |
19 using is_constexpr = decltype(is_constexpr_impl<p>(0)); | |
20 | |
21 constexpr int f() { return 0; } | |
22 int g() { return 0; } | |
23 | |
24 static_assert(is_constexpr<f>(), ""); | |
25 static_assert(!is_constexpr<g>(), ""); |