What was once known as std::experimental::optional is now known as std::optional in C++17.
But some libraries -- such as libpqxx -- haven't yet been updated to drop the experimental namespace.
So now with the new version of Ubuntu 18.10 which comes with g++ v8.2.0, attempting to compile projects that use libpqxx results in errors like this:
/usr/include/pqxx/internal/statement_parameters.hxx:213:13: error: ‘experimental’ in namespace ‘std’ does not name a type const std::experimental::optional<Arg> &arg) ^~~~~~~~~~~~ /usr/include/pqxx/internal/statement_parameters.hxx:213:35: error: expected unqualified-id before ‘<’ token const std::experimental::optional<Arg> &arg) ^ /usr/include/pqxx/internal/statement_parameters.hxx:213:35: error: expected ‘)’ before ‘<’ token const std::experimental::optional<Arg> &arg) ^ ) Is there some sort of flag I can pass in to g++ so it defines that old experimental namespace?
These are the relevant version numbers in Ubuntu 18.10:
> dpkg -l | egrep "libpqxx|g\+\+" ii g++ 4:8.2.0-1ubuntu1 amd64 GNU C++ compiler ii g++-8 8.2.0-7ubuntu1 amd64 GNU C++ compiler ii libpqxx-6.2 6.2.4-4 amd64 C++ library to connect to PostgreSQL ii libpqxx-dev 6.2.4-4 amd64 C++ library to connect to PostgreSQL (development files)
experimental::optionalstill exists in libstdc++, and is still in the<experimental/optional>header. Is that include just missing?std::optionalwhen possible, but apparently its build system misdetects this feature. The release note says you can fix the error by definingPQXX_HIDE_EXP_OPTIONAL.