I'd like to use optionals in my Android app's C++ code, but I'm having trouble figuring out how to configure the STL to support either std::experimental::optional or std::optional. I get a build failure, "cannot find -lc++experimental," if I just add "-lc++experimental" to the cppFlags. This is what the externalNativeBuild portion of my Gradle file looks like presently.
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=c++_shared"
cppFlags "-std=c++11", "-frtti", "-fexceptions"
}
}
How can I enable the use of std::optional or std::experimental::optional?
EDIT: I was able to download boost and use boost::optional instead, which was easy enough since it's a header-only library. Still, it would be nice to know how to to use one of the STLs that ships with the NDK, if that's possible. When I open up $ANDROID_NDK_HOME/sources/cxx-stl/llvm-libc++/include/experimental/optional, I see what looks like an implementation of std::experimental::optional, but it's surrounded by a lot of preprocessor statements that I imagine are disabling it.