Closed HumblePresent closed 2 months ago
That functionality would depend on an implementation of is_trivially_destructible<T>
being available.
Some of the type traits in the STL are impossible to implement in pure C++. Therefore the ETL would have to depend on either the STL being used, or the relevant intrinsics being available for the development compiler.
This is one of the more complex parts of the ETL to manage. It's something I hope to refactor at some point in the future.
I didn't realize is_trivially_destructible<T>
is dependent on compiler intrinsics. I understand that is a difficult thing to manage in a cross-platform library like this. Anyway, thank you for the quick response and maintenance of this library in general. It is much appreciated. Feel free to close this issue if you feel it's more of a "wishlist" type request at this time.
I came across this issue as well hoping to store an array of etl::variants in ROM via constexpr. Alas I couldn't because of it being non-trivially destructible.
Likewise, thank you for the maintenance of this library.
With the current implementation of
etl::variant
, any instance will always have a non-trivial destructor as defined here and here. According to the cppreference page forstd::variant
, its destructor is trivial ifstd::is_trivially_destructible_v<T>
istrue
for all variant types. The fact thatetl::variant
always has a non-trivial destructor, regardless of the variant types, prevents it and any derivatives likeetl::expected
from being used in functions markedconstexpr
. I am wondering ifetl::variant
could be specialized for cases where all variant types are trivially destructible, so that it behaves the same asstd::variant
.