-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP306.StructuredBinding.cpp
More file actions
30 lines (28 loc) · 889 Bytes
/
Copy pathP306.StructuredBinding.cpp
File metadata and controls
30 lines (28 loc) · 889 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
#include <iostream>
#include <utility>
#include <tuple>
#include <type_traits>
struct MaybeInt
{
bool valid;
int value;
};
MaybeInt g()
{
return {true, 10};
}
int main(int argc, char const *argv[])
{
const auto &&[b, N] = g();
auto [i, d] = std::tuple<int, double>{5, 10.4};
std::cout << std::boolalpha;
std::cout << std::is_rvalue_reference_v<decltype(i)> << std::endl;
std::cout << std::is_rvalue_reference_v<decltype(d)> << std::endl;
std::cout << std::is_lvalue_reference_v<decltype(i)> << std::endl;
std::cout << std::is_lvalue_reference_v<decltype(d)> << std::endl;
std::cout << std::is_reference_v<decltype(i)> << std::endl;
std::cout << std::is_reference_v<decltype(d)> << std::endl;
std::cout << std::is_same_v<decltype(i), int> << std::endl;
std::cout << std::is_same_v<decltype(d), double> << std::endl;
return 0;
}