Merge 7ea723c077109c8dfd98adf325134c677db077f0 into 60ba92928e8af3441f2a4eea5f18fd2563d98ad0

This commit is contained in:
Björn Schäpers 2026-10-14 14:12:57 +01:00 committed by GitHub
commit 6120fbff52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 4 deletions

View File

@ -401,8 +401,6 @@ namespace etl
/// Defines the parameter types
using const_key_reference = const key_type&;
static_assert((etl::is_default_constructible<key_type>::value), "key_type must be default constructible");
#include "private/diagnostic_uninitialized_push.h"
//*************************************************************************
///\brief Construct a const_set from a variadic list of elements.
@ -420,6 +418,9 @@ namespace etl
{
static_assert((etl::are_all_same<value_type, etl::decay_t<TElements>...>::value), "All elements must be key_type");
static_assert(sizeof...(elements) <= Size, "Number of elements exceeds capacity");
static_assert(sizeof...(elements) == Size || etl::is_default_constructible<key_type>::value,
"key_type must be default constructible, if providing less than Size elements");
}
#include "private/diagnostic_pop.h"
@ -454,8 +455,6 @@ namespace etl
using const_iterator = typename base_t::const_iterator;
using size_type = typename base_t::size_type;
static_assert((etl::is_default_constructible<key_type>::value), "key_type must be default constructible");
//*************************************************************************
///\brief Default construct a const_set.
//*************************************************************************

View File

@ -1381,5 +1381,22 @@ namespace
CHECK_TRUE(greater_than_equal11);
#endif
}
//*************************************************************************
TEST(test_construct_from_not_default_constuctible)
{
struct F : Key
{
constexpr explicit F(char c)
: Key(c)
{
}
};
using Set = etl::const_set<F, 3>;
static const Set set{F('1'), F('2'), F('3')};
CHECK_TRUE(set.is_valid());
}
}
} // namespace