Normally the =
in a variable declaration is treated by the compiler as move construction. For example:
vector<int> foo = vector<int>(13, 0);
Will call the vector<int>::vector<int>(vector<int>&&)
constructor.
How does this work with make_pair
? Am I constructing a temporary and moving it if I do:
pair<int, int> foo = make_pair(13, 0);
Obviously the consequence becomes more significant as the types in the pair
are something heavier than int
s, but the question remains the same. Is a temporary constructed here? If make_pair
forces a temporary, I assume I could call:
pair<int, int> foo = pair(13, 0);
Either way, what about when the types can be implicitly converted, but are not identical? For example:
pair<string, int> foo = make_pair<"Hello World!", 13>;
Or:
pair<string, int> foo = pair("Hello World!", 13);
Is a temporary pair<const char*, int>
created in this situation?