Skip to content

Commit

Permalink
variant varadic default constructed state (#804)
Browse files Browse the repository at this point in the history
* fixed variant varadic default constructed state

* updated testcases to account for default contructor changes
  • Loading branch information
fermentedfly authored Feb 22, 2024
1 parent 8403165 commit 134f8e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/etl/private/variant_variadic.h
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ namespace etl

default_construct_in_place<type>(data);
operation = operation_type<type, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
type_id = 0U;
type_id = variant_npos;
}
#include "diagnostic_pop.h"

Expand Down
10 changes: 5 additions & 5 deletions test/test_variant_variadic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,15 +420,15 @@ namespace

test_variant_etl_3 variant_etl;

CHECK(etl::holds_alternative<char>(variant_etl));
CHECK(!etl::holds_alternative<char>(variant_etl));
CHECK(!etl::holds_alternative<int>(variant_etl));
CHECK(!etl::holds_alternative<std::string>(variant_etl));

CHECK(etl::holds_alternative<0U>(variant_etl));
CHECK(!etl::holds_alternative<0U>(variant_etl));
CHECK(!etl::holds_alternative<1U>(variant_etl));
CHECK(!etl::holds_alternative<2U>(variant_etl));

CHECK(etl::holds_alternative(0U, variant_etl));
CHECK(!etl::holds_alternative(0U, variant_etl));
CHECK(!etl::holds_alternative(1U, variant_etl));
CHECK(!etl::holds_alternative(2U, variant_etl));
CHECK(!etl::holds_alternative(99U, variant_etl));
Expand Down Expand Up @@ -1830,7 +1830,7 @@ namespace
//*************************************************************************
TEST(test_variant_visit_void)
{
etl::variant<int8_t, uint8_t> variant1;
etl::variant<int8_t, uint8_t> variant1 = int8_t{};

bool variant_was_signed{};
auto const f = [&variant_was_signed](auto v)
Expand All @@ -1857,7 +1857,7 @@ namespace

std::string result = "?";

etl::variant<TypeA, TypeB, TypeC, TypeD> package;
etl::variant<TypeA, TypeB, TypeC, TypeD> package = TypeA{};

etl::visit(etl::overload
{
Expand Down

0 comments on commit 134f8e4

Please sign in to comment.