aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1z/constexpr-aggr-base1.C
blob: 06acb4a9f78fa6a9090a1d5e4b8e00640f5d83b7 (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
// PR c++/105795
// { dg-do compile { target c++17 } }

struct empty
{};

template <typename T>
struct tuple_holder
{
    [[no_unique_address]] T value;
};

struct tuple : tuple_holder<int>, tuple_holder<empty>
{};

constexpr auto make_tuple(int&& i, empty&& e)
{
    return tuple{i, e};
}

constexpr int foo()
{
    auto tuple = make_tuple(1, empty{});
    return static_cast<const tuple_holder<int>&>(tuple).value;
}

static_assert (foo() == 1);