Tuesday 8 January 2019

c++ - Advantages of using forward

In perfect forwarding, std::forward is used to convert the named rvalue references t1 and t2 to unnamed rvalue references. What is the purpose of doing that? How would that affect the called function inner if we leave t1 & t2 as lvalues?



template 

void outer(T1&& t1, T2&& t2)
{
inner(std::forward(t1), std::forward(t2));
}

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...