Can I use previous mapped object to create a new one?

Let's say I have code like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <unordered_map>

#include "MyClass.h"

int main()
{       
        std::unordered_map<int, MyClass> mc_map;

        mc_map[0] = MyClass(0); // Create the first object
        mc_map[1] = MyClass(1); // Create the second object

        // Create a third object based on the previous two and put it
        // in the place of the first object
        mc_map[0] = MyClass(mc_map[0], mc_map[1]); // <--- THIS LINE

        return 0;
}


Is this the marked line valid? The object `mc_map[0]` wouldn't be destroyed before it is read from by the `MyClass(MyClass, MyClass)` constructor, right?
Yes.
Thanks :D
Topic archived. No new replies allowed.