blob: 38ae7a0c0e104139de16340705dca4cec818ec4f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// PR c++/120555
// { dg-do compile { target c++17 } }
struct A { int m; };
template<class T>
constexpr auto f() {
if constexpr (sizeof(T) == sizeof(int))
return 1;
else
return A{f<int>()};
}
static_assert(f<bool>().m == 1);
static_assert(f<int>() == 1);
template <class T> constexpr auto g();
template<class T>
constexpr auto f2() {
if constexpr (sizeof(T) == sizeof(int))
return 1;
else
return A{g<int>()}; // { dg-error "auto" }
}
template <class T> constexpr auto g() { return A{1}; }
static_assert(f2<bool>().m == 1);
static_assert(f2<int>() == 1);
|