Vincent Vincent - 21 days ago 11x
C++ Question

Implementation status of std::optional in g++/libstdc++?

As I am working on a C++ library that will be released publicly around 2014, I currently have design choices to make. One of the very useful tool that will be released with C++14 is

. I would like to know with what version of
I can expect to have it using


Update (Oct 2016): std::optional was not in the final C++14 standard, so it is never available with -std=c++1y. Instead GCC 4.9 includes std::experimental::optional which is avilable with -std=c++1y.

GCC 7 will include std::optional with -std=c++1z i.e. C++17.

Original answer (Jun 2013):

It's currently unimplemented, see for the status of C++14 features in GCC's trunk.

When it gets implemented depends on when someone volunteers to do the work, so is impossible to predict.

I would expect it will be done for GCC 4.9, which should be released shortly before the C++14 standard, but there are no guarantees. It is unlikely to get added to GCC 4.8 though, as that's already released and unlike GCC 4.9 (i.e. the GCC subversion trunk) the __cplusplus macro has the same value for -std=c++11 and -std=c++1y so for GCC 4.8 there's no way to selectively enable features for -std=c++1y only.