Most Arduino Core don't include the Standard C++ Library, that's why headers like <vector>
and <string>
are missing.
This decision makes a lot of sense because the STL relies heavily on heap allocation, which would ruin the little RAM of the microcontroller.
If you're looking for an alternative to the STL, you might check out the ETL, the Embedded Template Library.. However, the code will not be the same because all the containers of the ETL have a fixed capacity. Here is a string for example:
etl::string<32> s = "hello world";
In practice, I never saw a project using the ETL. Most projects use the standard Arduino classes (String
, Stream
, Print
...) and learn to live with their flaws. Since there are no generic container classes in the Arduino core, the common usage is to use plain old C arrays.