396 auto const testTuple = std::make_tuple<TestTaggedA, TestTaggedB, TestTaggedA>( 1, 2, 3 );
397 assert((std::get<0>(testTuple).
value == 1));
398 assert((std::get<1>(testTuple).
value == 2));
399 assert((std::get<2>(testTuple).
value == 3));
403 assert(get<1U>(testTuple).
value == 2);
406 assert((util::getByExtractedType<TestExtractTag, TestTagB>(testTuple).
value == 2));
413 auto data = my::make_my_tuple<DataA, DataC, DataB>(64,
'b', 66);
414 auto dataWithDupl = my::make_my_tuple<DataA, DataC, DataA>(64,
'b', 66);
420 static_assert(std::is_same<std::decay_t<decltype(get<0U>(data ))>, DataA>(),
"Unexpected type 1");
421 static_assert(std::is_same<std::decay_t<decltype(get<1U>(data ))>, DataC>(),
"Unexpected type 2");
422 static_assert(std::is_same<std::decay_t<decltype(get<2U>(data ))>, DataB>(),
"Unexpected type 3");
423 static_assert(std::is_same<std::decay_t<decltype(get<0U>(dataWithDupl))>, DataA>(),
"Unexpected type 1 (dupl)");
424 static_assert(std::is_same<std::decay_t<decltype(get<1U>(dataWithDupl))>, DataC>(),
"Unexpected type 2 (dupl)");
425 static_assert(std::is_same<std::decay_t<decltype(get<2U>(dataWithDupl))>, DataA>(),
"Unexpected type 3 (dupl)");
431 static_assert(std::is_same<std::decay_t<decltype(get<DataA>(data))>, DataA>(),
"Unexpected type 1" );
432 static_assert(std::is_same<std::decay_t<decltype(get<DataC>(data))>, DataC>(),
"Unexpected type 2" );
433 static_assert(std::is_same<std::decay_t<decltype(get<DataB>(data))>, DataB>(),
"Unexpected type 3" );
435 static_assert(std::is_same<std::decay_t<decltype(get<DataC>(dataWithDupl))>, DataC>(),
"Unexpected type 2 (dupl)");
442 static_assert(std::is_same<std::tuple_element_t<0U, decltype(data )>, DataA>(),
"Unexpected type 1");
443 static_assert(std::is_same<std::tuple_element_t<1U, decltype(data )>, DataC>(),
"Unexpected type 2");
444 static_assert(std::is_same<std::tuple_element_t<2U, decltype(data )>, DataB>(),
"Unexpected type 3");
445 static_assert(std::is_same<std::tuple_element_t<0U, decltype(dataWithDupl)>, DataA>(),
"Unexpected type 1 (dupl)");
446 static_assert(std::is_same<std::tuple_element_t<1U, decltype(dataWithDupl)>, DataC>(),
"Unexpected type 2 (dupl)");
447 static_assert(std::is_same<std::tuple_element_t<2U, decltype(dataWithDupl)>, DataA>(),
"Unexpected type 3 (dupl)");
452 static_assert(std::tuple_size<decltype(data )>() == 3U,
"Unexpected tuple size");
453 static_assert(std::tuple_size<decltype(dataWithDupl)>() == 3U,
"Unexpected tuple size (dupl)");
463 static_assert(
util::index_of_type<DataC, decltype(dataWithDupl)>() == 1U,
"Unexpected type 2 (dupl)");
473 static_assert(
util::index_of_tag<
TagC, decltype(dataWithDupl)>() == 1U,
"Unexpected tagged type 2 (dupl)");
483 static_assert(std::is_same<
util::type_with_tag_t<
TagC, decltype(dataWithDupl)>, DataC>(),
"Unexpected tagged type 2 (dupl)");
489 static_assert(
util::has_type<DataA, decltype(data) >(),
"Unexpected type 1");
490 static_assert(
util::has_type<DataC, decltype(data) >(),
"Unexpected type 2");
491 static_assert(
util::has_type<DataB, decltype(data) >(),
"Unexpected type 3");
492 static_assert(
util::has_type<DataA, decltype(dataWithDupl)>(),
"Unexpected type 1 (dupl)");
493 static_assert(
util::has_type<DataC, decltype(dataWithDupl)>(),
"Unexpected type 2 (dupl)");
494 static_assert(!
util::has_type<DataB, decltype(dataWithDupl)>(),
"Unexpected type 3 (dupl)");
499 static_assert(
util::has_tag<
TagA, decltype(data) >(),
"Unexpected tagged type 1");
500 static_assert(
util::has_tag<
TagC, decltype(data) >(),
"Unexpected tagged type 2");
501 static_assert(
util::has_tag<
TagB, decltype(data) >(),
"Unexpected tagged type 3");
502 static_assert(
util::has_tag<
TagA, decltype(dataWithDupl)>(),
"Unexpected tagged type 1 (dupl)");
503 static_assert(
util::has_tag<
TagC, decltype(dataWithDupl)>(),
"Unexpected tagged type 2 (dupl)");
504 static_assert(!
util::has_tag<
TagB, decltype(dataWithDupl)>(),
"Unexpected tagged type 3 (dupl)");
509 static_assert(
util::count_types<DataA, decltype(data) >() == 1,
"Unexpected type 1");
510 static_assert(
util::count_types<DataC, decltype(data) >() == 1,
"Unexpected type 2");
511 static_assert(
util::count_types<DataB, decltype(data) >() == 1,
"Unexpected type 3");
512 static_assert(
util::count_types<DataA, decltype(dataWithDupl)>() == 2,
"Unexpected type 1 (dupl)");
513 static_assert(
util::count_types<DataC, decltype(dataWithDupl)>() == 1,
"Unexpected type 2 (dupl)");
514 static_assert(
util::count_types<DataB, decltype(dataWithDupl)>() == 0,
"Unexpected type 3 (dupl)");
522 static_assert(
util::count_tags<
TagA, decltype(dataWithDupl)>() == 2,
"Unexpected type 1 (dupl)");
523 static_assert(
util::count_tags<
TagC, decltype(dataWithDupl)>() == 1,
"Unexpected type 2 (dupl)");
524 static_assert(
util::count_tags<
TagB, decltype(dataWithDupl)>() == 0,
"Unexpected type 3 (dupl)");
541 static_assert(std::is_same<std::decay_t<decltype(util::getByTag<TagA>(data) .data)>,
int >(),
"Unexpected type 1" );
542 static_assert(std::is_same<std::decay_t<decltype(util::getByTag<TagC>(data) .data)>,
char>(),
"Unexpected type 2" );
543 static_assert(std::is_same<std::decay_t<decltype(util::getByTag<TagB>(data) .data)>,
int >(),
"Unexpected type 3" );
545 static_assert(std::is_same<std::decay_t<decltype(util::getByTag<TagC>(dataWithDupl).data)>,
char>(),
"Unexpected type 2 (dupl)");
548 assert((util::getByTag<TagA>(data) ).data == 64);
549 assert((util::getByTag<TagC>(data) ).data ==
'b');
550 assert((util::getByTag<TagB>(data) ).data == 66);
552 assert((util::getByTag<TagC>(dataWithDupl)).data ==
'b');
Tag class parametrized by a sequence of numbers.