[libcxx-dev] Using optional before C++17
Louis Dionne via libcxx-dev
libcxx-dev at lists.llvm.org
Mon Apr 1 11:03:03 PDT 2019
> On Mar 29, 2019, at 16:19, Shoaib Meenai via libcxx-dev <libcxx-dev at lists.llvm.org> wrote:
> We have a codebase that’s built with C++14 and was using <experimental/optional> to use std::optional. This no longer works with libc++ 7 onwards, since <experimental/optional> was removed per the TS deprecation policy.
> We can’t use <optional> because that’s limited to C++17 and above. We’re working on upgrading our codebase, but it’ll take time :) I’m wondering if there’s any solution available that’ll work pre-C++17. Our current plan was to overlay our own <experimental/optional> that’s a copy of the one from libc++ 6, but some sort of solution in the library itself would be ideal.
> I recall there being some past discussion about this, but I can’t find it right now. Looking forward to any suggestions here.
Unfortunately, I don't know of any other solution. In retrospect, we should have added a deprecation warning to experimental::optional one year before removing it so as to give a heads up to people. However, now that it has been removed, there isn't a workaround. I've suggested to other people that they use boost::optional pre-c++17, but that is obviously not an optimal solution.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the libcxx-dev