I'm trying to use std::optional in an Xcode 12.0 Mac OS project. I'm getting the error: No template named 'optional' in namespace 'std'
#include <optional>
std::optional<int> o;
My settings are (I need libc++ for project):
The version of libc++ that Apple ships as part of Xcode 12 (and 11) includes support for many C++17 features, including optional
. See the Xcode 11 release notes.
The text in Xcode that says that libc++ "supports C++11" is in contrast to the standard library (libstdc++ v 4.2.1) that Apple used to ship - that did not support C++11. It does not mean that it only supports C++11 to the exclusion of C++14/17/20/etc.
The OP mentioned in a comment that he had a -std=gnu++11
in the "Other flags" that was causing the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With