Debian Codegraph @

gcc/testsuite/g++.dg/cpp1y/constexpr-108158.C

raw
1 // PR c++/108158
2 // { dg-do compile { target c++14 } }
3
4 template <class T, int N> struct carray {
5 T data_[N]{};
6 constexpr T operator[](long index) const { return data_[index]; }
7 };
8 struct seed_or_index {
9 private:
10 long value_ = 0;
11 };
12 template <int M> struct pmh_tables {
13 carray<seed_or_index, M> first_table_;
14 template <typename KeyType, typename HasherType>
15 constexpr void lookup(KeyType, HasherType) const {
16 first_table_[0];
17 }
18 };
19 template <int N> struct unordered_set {
20 int equal_;
21 carray<int, N> keys_;
22 pmh_tables<N> tables_;
23 constexpr unordered_set() : equal_{} {}
24 template <class KeyType, class Hasher>
25 constexpr auto lookup(KeyType key, Hasher hash) const {
26 tables_.lookup(key, hash);
27 return keys_;
28 }
29 };
30 constexpr unordered_set<3> ze_set;
31 constexpr auto nocount = ze_set.lookup(4, int());
32 constexpr auto nocount2 = unordered_set<3>{}.lookup(4, int());