How to pass the std::string to the function to gain in speed of execution for this code snippet (strictly C++14, function only prints or logs received string):
#include <iostream>
void myFunction1(std::string msg)// this is faster ?
{
std::cout << msg;
}
void myFunction2(const std::string& msg)// to this one is fastest?
{
std::cout << msg;
}
int main()
{
myFunction("Hello World");
myFunction("Long string of 127 characters");
myFunction("Another long string of 256 characters");
return 0;
}