Hi, I hope this question fits here.
Whenever I’m reading about Arduino developement, people write that the std lib is not ported to Arduino for understandable reasons and you’d need to import some particular projects. However, when creating a PIO project, in particular std::vector
is available after #import <Ardunio.h>
, specifically #import <vector>
(std::vector
is defined in packages/toolchain-xtensa/xtensa-*/.../stl_vector.h
). I’m using PIO with CLion but that shouldn’t change the build process I think.
Now, two questions:
- Is this intended behaviour / are these
xtensa
-provided packages intended to be used? - How stable / safe is it to use is this vector implementation? I’m very new to C++, so I might be doing something wrong, but I experienced quite some problems when using global-scope nested vectors, for example when defining
const std::vector<std::vector<int>> ints = { ... };
globally.ints
seems to be de-allocated inloop()
. However, as I said, I’m a novice and I might be doing something wrong. My issue is that I simply can’t find any reference / doc on this implementation because every post I find for"arduino std::vector"
tells me thatstd::vector
is not available. I could imagine that I for some reason can’t use them at global scope or I have tonew
them?
Cheers