Why is move ctor called when creating a std::pair?
Hi,
In the following code:
1 2
|
const int val = 1;
auto xx = make_pair(val, A{ val });
|
the move constructor of A is called. Why? It creates a temporary object which is destroyed afterwards -- seems unnecessary...
Thanks,
Juan
No, I got it - sorry.
There is actually a temporary object being created in A{val} and this is an rvalue which calls A(A&&)...
Thanks,
Juan
Topic archived. No new replies allowed.