The STL is not part of Arduino and no support for libstc++ from AVR.
My "answer" differences from Malachi at one point though, as explained in the comments.
I don't think you shouldn't, just because "most people say" that you shouldn't. There are a lot of people that even think you shouldn't use C++ at all.
The problem is that C++ (and C++ standard library) are very powerful and may be ported in a non-efficient way.
Why use libstdc++?
I think, however, that if you use it with care, it can be very usefull.
Let's say we've got two buffers, a send buffer and a receive buffer.
With C, you would store them in a fixed char array. In C++ you can use dynamic containers.
So in C, you'll use 2x 256 bytes of memory to save your messages. Any longer message won't fit.
In C++ you'll use only whatever bytes are needed at one point (plus some extra probably). And if you get a longer message, it will simply scale up.
If the C++ thing works for you, and just test it very very well, why not use it? On average, it will use less memory, since you don't assign all of it when it's not used. You will have a problem when your messages get too big, since your memory will overflow, often causing the microcontroller to reset. But if more buffers in your program are dynamic, one may leave some space for the other, etc. Effectively using the memory more efficient!
But, without dynamic allocation, it might be a little safer, since you've already claimed those pieces of memory, there is no way you can't use those pieces. Any message that is bigger, simply won't fit, but you can easily check on that. Another thing is that the C++ stl's you find, might not be as well optimalised for your architecture/microcontroller.
Also, creating your very own dynamic storage in C may cause even more problems than the C++ stl ;). And it's not like you have to use dynamic storage for everything, simply being able to do so is nice.
Current microcontrollers are also getting much more serious as the 8-bit Arduino's (328P). 20$ can get you a Teensy 3.2 which has
256K Flash Memory, 64K RAM so, in this case, dynamic memory can be very useful (if you are certain you always have enough memory left).
All STM32F41xxx products embed: Up to 192 Kbytes of system SRAM including 64 Kbytes of CCM (core coupled memory) data RAM
By that, it can also be a very nice way to learn C++ and program in the same language as you do on the PC.
But keep in mind that on an 8-bit micro, you should check if your stl-functions don't give too much overhead.
How use C++ standard template library for AVR?
I've followed the blog from Andy Brown and now have iterators/string/vectors working in AtmelStudio.
Though I did get some errors, the first batch of errors included:
Error '_M_deallocate' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] D:\avr-stl\include\string 173
Message declarations in dependent base 'std::_String_alloc_base<char, std::allocator<char>, true>' are not found by unqualified lookup D:\avr-stl\include\string 173
Message use 'this->_M_deallocate' instead D:\avr-stl\include\string 173
This error actually explains itself; you should use
After that I got
undefined reference to "operator new(unsigned int, void*). But I fixed it by including "pnew.cpp" right under
#include <new> in
stl_construct.h which is weird, but it works.
(Piece of stl_construct.h)