3 ms·
That's not exactly true. In C++ terms, the example code is moving a value: std::map<...> foo; someFunction(std::move(foo)); And not moving a pointer like
by ahupp 6y ago
That's not exactly true. In C++ terms, the example code is moving a value:
std::map<...> foo;
someFunction(std::move(foo));
And not moving a pointer like:
std::unique_ptr<std::map<...>> foo = ...;
someFunction(std::move(foo));
So it copies sizeof(std::map<...>), not a pointer.
- pjmlp 6y agoNot necessary, std::map::map(&&) is free to move just the internal pointers and bookkeeping data, only dumb implementations would move the memory blocks where the map data is actually stored, as per ISO C++ requirements.
- ahupp 6y agoThe comment originally said it was the cost of a pointer copy, and I was pointing out it's not a pointer. eg., sizeof(std::map<std::string,std::string>) is 48, which is the "pointers and bookeeping" you mention.
- pjmlp 6y agoAh sorry for the misinterpretation. Should have payed more attention.