There are lots of threads about this topic – PlatformIO uses Arduino-ESP32 1.0.6 and 2.0.x support is currently an open issue.
As explained in Which C++ standard am I using? - #4 by maxgerhardt, one can currently use the platformio.ini
[env:esp32dev]
platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-master
board = esp32dev
framework = arduino
platform_packages =
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.1
to get a preview of 2.0.1.