@@ -40,6 +40,21 @@ static_assert(bounded::constructible_from<thing_t, short>);
4040static_assert (bounded::constructible_from<thing_t , long >);
4141static_assert (bounded::constructible_from<thing_t , char >);
4242
43+ constexpr auto check_index_and_value (auto const index, auto const value) -> bool {
44+ auto const v = thing_t (index, value);
45+ BOUNDED_ASSERT (v.index () == index);
46+ auto const stored = v[index];
47+ static_assert (std::same_as<decltype (stored), decltype (value)>);
48+ BOUNDED_ASSERT (stored == value);
49+ return true ;
50+ }
51+
52+ static_assert (check_index_and_value(0_bi, 7 ));
53+ static_assert (check_index_and_value(1_bi, short (7 )));
54+ static_assert (check_index_and_value(2_bi, 7L ));
55+ static_assert (check_index_and_value(3_bi, ' A' ));
56+ static_assert (check_index_and_value(4_bi, 7 ));
57+
4358static_assert (thing_t (0_bi, 0 ) == thing_t (0_bi, 0 ));
4459static_assert (thing_t (0_bi, 0 ) != thing_t (0_bi, 1 ));
4560static_assert (thing_t (0_bi, 0 ) != thing_t (1_bi, static_cast <short >(0 )));
@@ -48,22 +63,9 @@ static_assert(thing_t(0_bi, 0) != thing_t(4_bi, 1));
4863
4964static_assert (thing_t (1_bi, static_cast <short >(5 )) == thing_t (static_cast <short >(5 )));
5065
51- static_assert (thing_t (0_bi, 0 ).index() == 0_bi);
52- static_assert (thing_t (1_bi, static_cast <short >(0 )).index() == 1_bi);
53- static_assert (thing_t (2_bi, 0 ).index() == 2_bi);
54- static_assert (thing_t (3_bi, ' \0 ' ).index() == 3_bi);
55- static_assert (thing_t (4_bi, 0 ).index() == 4_bi);
56-
5766constexpr auto index = 1_bi;
5867constexpr auto value = static_cast <short >(8 );
5968
60- constexpr auto thing = thing_t (index, value);
61- using thingy = decltype (thing[index]);
62-
63- static_assert (std::same_as<thingy, short const &>);
64-
65- static_assert (thing[index] == value);
66-
6769constexpr auto test_assignment_from_variant () {
6870 auto thing1 = thing_t (index, value);
6971 thing1 = thing_t (index, value);
0 commit comments