#include
#include
#include
using namespace std::literals;
int main()
{
auto coll = std::set{ \"hello\"s };
auto
No.
While @NathanOliver points out that an element will not be inserted if and only if there is no equivalent key, it does not guarantee that the arguments will not be modified.
In fact, [map.modifiers] says the following
template
pair insert(P&& x);
equivalent to
return emplace(std::forward
(x)).
Where emplace
may perfectly forward the arguments to construct another P
, leaving x
in some valid but indeterminate state.
Here's an example that also demonstrates (not proves) that with std::map
(an associative container), a value gets moved around a bit:
#include
#include
#include
#include