any: cleanup further

This commit is contained in:
Michele Caini
2024-12-09 17:13:43 +01:00
parent 8e792df7f7
commit adcf929fdf
2 changed files with 5 additions and 4 deletions

1
TODO
View File

@@ -44,4 +44,5 @@ TODO:
* built-in no-pagination storage - no_pagination page size as limits::max
* meta_any ownership construction and from_void
* sparse_set shrink_to_fit argument for sparse array shrink policy (none, empty, deep, whatever)
* any cdynamic to support const ownership construction
* track meta context on meta elements

View File

@@ -109,9 +109,9 @@ class basic_any {
template<typename Type, typename... Args>
void initialize([[maybe_unused]] Args &&...args) {
using plain_type = std::remove_cv_t<std::remove_reference_t<Type>>;
if constexpr(!std::is_void_v<Type>) {
using plain_type = std::remove_cv_t<std::remove_reference_t<Type>>;
info = &type_id<plain_type>();
vtable = basic_vtable<plain_type>;
@@ -178,10 +178,10 @@ public:
*/
template<typename Type>
explicit basic_any(std::in_place_t, Type *value)
: instance{value} {
: instance{} {
static_assert(!std::is_const_v<Type> && !std::is_void_v<Type>, "Non-const non-void pointer required");
if(instance != nullptr) {
if(value != nullptr) {
initialize<Type &>(*value);
mode = any_policy::dynamic;
}