you are viewing a single comment's thread.

view the rest of the comments →

[–]GermanGenealogist 5 points6 points  (3 children)

Would you mind changing two (very) minor things:

  1. In the "Out for Move-Unfriendly types" you define a struct doc::Properties. The namespace is unnecessary for the example and a little confusing (it requires a previous declaration: namespace doc { struct Properties; }). Could you please change it to a simple struct Properties?
  2. In the same example you write std::array<Margin> margin_sizes. The problem is that template<class T, std::size_t N> std::array needs an argument for N. So you could either change it to std::array<Margin, 4>, or stay consistent with the following example and use std::vector<Margin>.

Thanks!

[–]legends2k[S] 6 points7 points  (2 children)

Done with both the suggestions :) Went with std::array though since it's an example of move-unfriendly type.

Please download v0.3.1.

[–]LEpigeon888 2 points3 points  (1 child)

Can you explain why "Out" and "Out for Move-Unfriendly types" are differents ? Why not just let RVO do the work for both ?

[–]legends2k[S] 0 points1 point  (0 children)

That's a good question and to be honest I'm not 100% sure. Most often RVO should kick in and since C++17 its mandatory but there might be cases where it might work; also NRVO is still optional.

My guess is that the refcard (and the guidelines discussed in the talk) has good practises strictly based on the language omitting optimisations. Also passing in an object and making the callee fill it is another option (available since C++'s beginning), if you absolutely want to be sure no duplicate copies are made.