Errors relating to modern (C++20, C++23, ...) features
At the time of writing, C++20 and C++23 are the most recent standards. Recent compilers support most, if not all of C++20, and a significant number of C++23 features.
However, you may want to check if your default compiler version does support the features you are trying to use.
My guess would be that VS Code uses the default compiler installation to check for syntax errors, and include errors.
For example, in my specific case, I have set the -std=c++23 compiler flag in the VS Code settings.
However, the default compiler on my system is still gcc version 12.2.0. This is not the most up to date version. The reason is this is a Debian system, and the toolchains tend to lag a bit behind the alternatives, for example Ubuntu server systems.
I wanted to use the new std::format and std::println features of C++23.
I get include errors related to the include lines for these headers.
#include <format>
#include <print>
One way to fix this would be to install a more up-to-date compiler.
However, rather than risk breaking your system install, I would suggest considering an alternative solution.
Docker can provide quite a nice solution. It is relatively easy to build a Dockerfile and a Docker container image which contains the latest gcc and g++ compilers.
This will not fix your include errors - you will have to just ignore them - but it is a nice solution to get access to a new compiler without risking breaking other parts of your install.
It is also much easier than installing a second compiler chain. (Which if not done carefully can also break parts of your system.)
I won't give further details here, because it is too much a tangent to the original question.
xcode-select --installand then restarting vscode solved the problem for me.g++installed.