> I want to believe that you meant canonical instead of "canical" in line 6 of your first code block.
Yes.
> Is this more efficient than the conventional method I used?
Optimisers are quite clever these days; so it probably won't be more machine efficient.
Arguably it is more programmer efficient.
> how is the input file stream an rvalue reference in this case?
In
loadFile( std::ifstream( "Spanish_MustKnow2.txt" ) );,
the expression
std::ifstream( "Spanish_MustKnow2.txt" ) initializes an anonymous temporary object.
The value category of such an expression is
prvalue ("pure" rvalue).
> In line 26, why are you using std::move again
The value category of the expression
str is
lvalue, the overload of
push which accepts an
lvalue would copy the object.
http://en.cppreference.com/w/cpp/container/queue/push
Note:
result.push( std::move(str) ) ;
and then reusing
str works because objects of types defined by the standard library (with a few exceptions which are explicitly stated) are guaranteed to be in a valid usable state even after they have been moved from.
> The optimization to which to refer, is this onus on the compiler or the programmer?
C++17 compilers are required to elide the copy.
Prior to C++17, copy elision is permitted, but not mandated (in practice, every compiler implements it).