9 char in[3] = {
'a',
'd',
'z'};
10 std::vector<size_t> out1;
11 std::vector<char> out2;
14 static_assert(std::is_same_v<
decltype(i),
const size_t&>);
15 static_assert(std::is_same_v<
decltype(
e),
char&>);
20 CHECK(out1 == std::vector<size_t>{0, 1, 2});
21 CHECK(out2 == std::vector{
'a',
'd',
'z'});
26 std::vector in{3, 9, 11};
27 std::vector<size_t> out;
30 static_assert(std::is_same_v<
decltype(i),
const size_t&>);
31 static_assert(std::is_same_v<
decltype(
e),
int&>);
33 e = narrow_cast<int>(2 *
e + i);
36 CHECK(in == std::vector{6, 19, 24});
37 CHECK(out == std::vector<size_t>{0, 1, 2});
constexpr auto enumerate(Iterable &&iterable)
Heavily inspired by Nathan Reed's blog post: Python-Like enumerate() In C++17 http://reedbeta....
TEST_CASE("enumerate: basic")