How to include C++ 17 headers with g++ 6.2.0 with -std=c++17 (optional, any, string_view, variant)

You can't.

GCC 6.2's support for C++17 is experimental, which is literally why the headers are arranged like this.

If only they'd done this for std::regex back in the day! It's a gift.

https://gcc.gnu.org/projects/cxx-status.html#cxx1z


I made a hacky workaround when faced with a situation like this:

#if defined(__GNUC__) && __GNUC__ < 7
# include <experimental/string_view>
# define string_view experimental::string_view
#else
# include <string_view>
#endif