-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtuple1.cxx
More file actions
31 lines (24 loc) · 800 Bytes
/
tuple1.cxx
File metadata and controls
31 lines (24 loc) · 800 Bytes
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
31
#feature on safety
#include <std2.h> // Pull in the definition of std2::tuple.
using T0 = (); // Zero-length tuple type.
using T1 = (int, ); // One-length tuple type.
using T2 = (int, double); // Longer tuples type.
// Nest at your leisure.
using T3 = (((int, double), float), char);
int main() {
// Zero-length tuple expression.
auto t0 = (,);
static_assert(T0 == decltype(t0));
// One-length tuple expression.
auto t1 = (4, );
static_assert(T1 == decltype(t1));
// Longer tuple expression.
auto t2 = (5, 3.14);
static_assert(T2 == decltype(t2));
// Nest tuples.
auto t3 = (((1, 1.618), 3.3f), 'T');
static_assert(T3 == decltype(t3));
// Access the 1.618 double field:
auto x = t3.0.0.1;
static_assert(double == decltype(x));
}