Do I understand it right that the C++14 standard library uses move semantics? In other words, can I be confident that I am using a move instead of a copy in the following program:
#include <iostream>
#include <string>
#include <vector>
using namespace std::string_literals;
std::vector<std::string> greeting()
{
std::vector<std::string> vs {"hello"s, "world"s};
return vs;
}
int main()
{
std::vector<std::string> s = greeting();
std::cout << s[0] << " " << s[1] << "\n" ;
}
Is there a way I can check?
How about in the following example:
#include <iostream>
#include <string>
#include <vector>
using namespace std::string_literals;
class Greeting {
public:
std::string first, second;
Greeting() { first = "hello"s ; second = "world"s ;};
};
Greeting greetingc()
{
Greeting g;
return g;
}
int main()
{
Greeting g = greetingc();
std::cout << g.first << " " << g.second << "\n" ;
}
Move, or copy?