Debian Codegraph @

gcc/testsuite/g++.dg/concepts/template-template-parm1.C

raw
1 // PR c++/66937
2 // { dg-do compile { target c++17 } }
3 // { dg-options "-fconcepts" }
4
5 #include <tuple>
6
7 namespace detail
8 {
9 template<typename T, template<typename...> class Sink>
10 struct copy_tuple_args_impl;
11
12 template<typename... Args, template<typename...> class Sink>
13 struct copy_tuple_args_impl<std::tuple<Args...>, Sink>
14 {
15 using type = Sink<Args...>;
16 };
17 }
18
19 // copy_tuple_args copies the template arguments of a tuple into another template
20 // copy_tuple_args does not care about constraints whatsoever.
21 template<typename Tuple, template<typename...> class Sink>
22 using copy_tuple_args = typename detail::copy_tuple_args_impl<Tuple, Sink>::type;
23
24 // A concept of a column
25 template <typename T>
26 concept Column =
27 requires()
28 {
29 typename T::_name_t;
30 };
31
32 // column_list is constrained to Column arguments
33 template<Column... C>
34 struct column_list
35 {
36 };
37
38 // Here are some columns
39 struct A
40 {
41 using _name_t = int;
42 };
43
44 struct B
45 {
46 using _name_t = int;
47 };
48
49
50 int main()
51 {
52 using ColumnTuple = std::tuple<A, B>;
53 using ColumnList = copy_tuple_args<ColumnTuple, column_list>; // This fails, but should not
54 }
55