-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
I am looking for C++14 optional drop-in which I can use in constexpr contexts. From the Readme it seems to fit my needs, because you state this implementation provides a LiteralType in that case. I tried to compile
int main()
{
constexpr nonstd::optional<int> o = 2;
}
with std=c++14 two different compilers (gcc-8 and clang-5) and both failed to compile the code.
While trying to fix the issue with custom patches I encountered following problems:
To make the type satisfy std::is_literal_type (deprecated, I know)
- I had to make the destructor of
optionaltrivial for trivially destructible typesT. This can be achieved by inheriting from a base class and using a template specialization. - I had to mark at least on constructor of storage
constexpr
To make the type usuable in constexpr contexts:
- placement new in
storage_tis not constexpr, sononstd::optionalwith this storage implementation is not going to be usable in constexpr contexts.
Did i misunderstand something terribly wrong and/or do you think it would be worthwhile to provide some patches to target the above points.
Metadata
Metadata
Assignees
Labels
No labels