Skip to content

Commit 787b561

Browse files
committed
utils_11
1 parent 5a7e771 commit 787b561

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

cpp/11.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,27 @@ static void lambda_capture(void)
464464
assert(inc_global() == 2);
465465
}
466466

467+
/// [utility](https://en.cppreference.com/w/cpp/utility)
468+
469+
void utils_11()
470+
{
471+
pair<int, int> bounds = minmax({3, 2, 1});
472+
assert(bounds.first == 1);
473+
assert(bounds.second == 3);
474+
int min, max;
475+
tie(min, max) = bounds;
476+
assert(min == 1);
477+
int n = 1;
478+
auto t = make_tuple(0, "one", 3.14, ref(n), n);
479+
n = 2;
480+
cerr << "typeid " << typeid(get<2>(t)).name() << '\n';
481+
//cerr << func_type(get<2>(t)) << '\n';
482+
assert(is_arithmetic<decltype(1)>::value);
483+
//assert(is_arithmetic<decltype(get<0>(t))>::value);
484+
assert(get<3>(t) == 2);
485+
assert(get<4>(t) == 1);
486+
}
487+
467488
/// [container](https://en.cppreference.com/w/cpp/container)
468489

469490
template <class L>
@@ -800,6 +821,7 @@ int main(void)
800821
lambda_basics();
801822
lambda_capture();
802823
lambda_complex();
824+
utils_11();
803825
container_11();
804826
algo_11();
805827
sort_11();

0 commit comments

Comments
 (0)