diff --git a/tiledb/sm/cpp_api/enumeration_experimental.h b/tiledb/sm/cpp_api/enumeration_experimental.h index af4b8aa1bf80..fc512618cf9d 100644 --- a/tiledb/sm/cpp_api/enumeration_experimental.h +++ b/tiledb/sm/cpp_api/enumeration_experimental.h @@ -239,17 +239,20 @@ class Enumeration { const std::string& name, std::vector& values, bool ordered = false, - tiledb_datatype_t type = static_cast(255)) { + std::optional type = std::nullopt) { using DataT = impl::TypeHandler; - if (type == static_cast(255)) { - type = DataT::tiledb_type; + tiledb_datatype_t dtype; + if (type.has_value()) { + dtype = type.value(); + } else { + dtype = DataT::tiledb_type; } return create( ctx, name, - type, + dtype, DataT::tiledb_num, ordered, values.data(), @@ -275,13 +278,16 @@ class Enumeration { const std::string& name, std::vector>& values, bool ordered = false, - tiledb_datatype_t type = static_cast(255)) { + std::optional type = std::nullopt) { using DataT = impl::TypeHandler; static_assert( DataT::tiledb_num == 1, "Enumeration string values cannot be compound"); - if (type == static_cast(255)) { - type = DataT::tiledb_type; + tiledb_datatype_t dtype; + if (type.has_value()) { + dtype = type.value(); + } else { + dtype = DataT::tiledb_type; } uint64_t total_size = 0; @@ -303,7 +309,7 @@ class Enumeration { return create( ctx, name, - type, + dtype, TILEDB_VAR_NUM, ordered, data.data(),