ETLCPP / etl

Embedded Template Library
https://www.etlcpp.com
MIT License
2.17k stars 388 forks source link

etl::optional cannot be constexpr #765

Closed tlane-jlg closed 1 year ago

tlane-jlg commented 1 year ago

Starting at this commit the following code sample is no longer possible in C++ 14 using the Clang compiler. I'm assuming this is unintentional given that std::optional works here in C++ 17. 

#include <iostream>

#include <etl/optional.h>

constexpr etl::optional<int> a;

int main() { std::cout << "Hello world!" << std::endl; }

These are the relevant parts of the error message:

error: constexpr variable cannot have non-literal type 'const etl::optional<int>'
note: 'optional<int, true>' is not literal because it has data member 'storage' of non-literal type 'etl::optional<int, true>::storage_type'
jwellbelove commented 1 year ago

Fixed 20.38.2