Skip to content

Commit

Permalink
test: add more test cases of struct binding
Browse files Browse the repository at this point in the history
Signed-off-by: Valentyn Yukhymenko <[email protected]>
  • Loading branch information
BaLiKfromUA committed Jun 22, 2024
1 parent 76cd9b0 commit 5420427
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,24 @@ static_assert(type_of(^x3) == ^const int);
static_assert(type_of(^y3) == ^const int);
static_assert(type_of(^z3) == ^const volatile double);

auto p = std::pair{1, 2};
auto& [x4, y4] = p;
static_assert(is_structured_binding(^x4));
static_assert(is_structured_binding(^y4));
static_assert(!is_variable(^x4));
static_assert(!is_variable(^y4));
static_assert(type_of(^x4) == ^int);
static_assert(type_of(^y4) == ^int);

int a = 1, b = 2;
const auto& [x5, y5] = std::tie(a, b); // x and y are of type int&
static_assert(is_structured_binding(^x5));
static_assert(is_structured_binding(^y5));
static_assert(!is_variable(^x5));
static_assert(!is_variable(^y5));
static_assert(type_of(^x5) == ^int&);
static_assert(type_of(^y5) == ^int&);

static_assert(!is_structured_binding(^var));
static_assert(!is_structured_binding(std::meta::reflect_value(3)));
} // namespace test_is_structured_binding_and_related_edge_cases
Expand Down

0 comments on commit 5420427

Please sign in to comment.