I ran into this problem recently and I think the preferable solution in a lot of cases may be to use clang++ instead.
If that's not possible; I was able to resolve the issue by explicitly linking against the std c++ library directly.
For example:
clang -std=c++17 main.cpp -lstdc++