Default is xtensa GCC 4.8.2, which doesn’t support C++17. Add the lines
platform_packages =
toolchain-xtensa@~2.100100.0
to your platformio.ini
for GCC 10.1.0 and retry.
This is pretty identical to what was already discussed here at Custom framework and toolset for Arduino ESP8266 3.0.0 - #2 by maxgerhardt.