Reputation: 20340
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)
Upvotes: 2
Views: 1700
Reputation: 20340
As @cpplearner pointed out in a comment above, libpqxx has a macro (PQXX_HIDE_EXP_OPTIONAL
) you can define prior to including the pqxx header files. More of a temporary workaround than a solution, but in my case it allowed me to get past the error and working on the code I needed.
This is the definition I added to my cmake file:
ADD_DEFINITIONS ( -DPQXX_HIDE_EXP_OPTIONAL )
Upvotes: 3