annotate gcc/testsuite/g++.dg/cpp0x/variadic-lambda.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // { dg-do compile { target c++11 } }
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 struct int_placeholder;
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 template<typename T>
kono
parents:
diff changeset
6 struct do_replace
kono
parents:
diff changeset
7 {
kono
parents:
diff changeset
8 typedef T type;
kono
parents:
diff changeset
9 };
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 template<>
kono
parents:
diff changeset
12 struct do_replace<int_placeholder>
kono
parents:
diff changeset
13 {
kono
parents:
diff changeset
14 typedef int type;
kono
parents:
diff changeset
15 };
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 template<typename T> struct lambdalike
kono
parents:
diff changeset
18 {
kono
parents:
diff changeset
19 typedef T type;
kono
parents:
diff changeset
20 };
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 template<template<typename...> class TT, typename... Args>
kono
parents:
diff changeset
23 struct lambdalike<TT<Args...> > {
kono
parents:
diff changeset
24 typedef TT<typename do_replace<Args>::type...> type;
kono
parents:
diff changeset
25 };
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 template<typename T, typename U>
kono
parents:
diff changeset
29 struct is_same
kono
parents:
diff changeset
30 {
kono
parents:
diff changeset
31 static const bool value = false;
kono
parents:
diff changeset
32 };
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 template<typename T>
kono
parents:
diff changeset
35 struct is_same<T, T>
kono
parents:
diff changeset
36 {
kono
parents:
diff changeset
37 static const bool value = true;
kono
parents:
diff changeset
38 };
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 template<typename... Elements> struct tuple;
kono
parents:
diff changeset
41 template<typename T1, typename T2> struct pair;
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 static_assert(is_same<lambdalike<tuple<float, int_placeholder, double>>::type,
kono
parents:
diff changeset
44 tuple<float, int, double>>::value,
kono
parents:
diff changeset
45 "MPL lambda-like replacement on tuple");
kono
parents:
diff changeset
46 static_assert(is_same<lambdalike<pair<float, int_placeholder>>::type,
kono
parents:
diff changeset
47 pair<float, int>>::value,
kono
parents:
diff changeset
48 "MPL lambda-like replacement on pair");
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 struct _1 {};
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 template<typename Arg0, typename Lambda>
kono
parents:
diff changeset
54 struct eval
kono
parents:
diff changeset
55 {
kono
parents:
diff changeset
56 typedef Lambda type;
kono
parents:
diff changeset
57 };
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 template<typename Arg0>
kono
parents:
diff changeset
60 struct eval<Arg0, _1>
kono
parents:
diff changeset
61 {
kono
parents:
diff changeset
62 typedef Arg0 type;
kono
parents:
diff changeset
63 };
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 template<typename Arg0, template<typename...> class T, typename... Pack>
kono
parents:
diff changeset
66 struct eval<Arg0, T<Pack...> >
kono
parents:
diff changeset
67 {
kono
parents:
diff changeset
68 typedef T< typename eval<Arg0, Pack>::type... > type;
kono
parents:
diff changeset
69 };
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 static_assert(is_same<eval<int, tuple<float, _1, double>>::type,
kono
parents:
diff changeset
72 tuple<float, int, double>>::value, "eval tuple");
kono
parents:
diff changeset
73 static_assert(is_same<eval<int, pair<_1, double>>::type,
kono
parents:
diff changeset
74 pair<int, double>>::value, "eval pair");
kono
parents:
diff changeset
75 static_assert(is_same<eval<int,
kono
parents:
diff changeset
76 tuple<pair<_1, _1>, pair<float, float>,
kono
parents:
diff changeset
77 pair<double, _1>>>::type,
kono
parents:
diff changeset
78 tuple<pair<int, int>, pair<float, float>, pair<double, int>>>::value,
kono
parents:
diff changeset
79 "recursive eval");