Re: Sample code for 'Effective Modern C++'
Hello group,
I was one of the reviewers for Scott Meyers his 'Effective Modern C++' book. During the review process, I have created lots of sample code for the material from the book. I am currently revising that sample code and uploading it to my GitHub repository https://github.com/BartVandewoestyne/Effective-Modern-Cpp I have 27 out of the 42 items online already, and hope to add the remaining 15 soon. Feel free to contribute by sending me pull requests! Comments and suggestions are also highly appreciated!
I hope that this online code will help the EMC++ readers to get a hands-on feeling for the principles explained in the book. Feel free to play with this code as much as you like and spread the message!
One thing that might be out of scope for the book, but something that I
wanted to understand when I read it, was how std::forward /really/
works. In the book and the example code it only brings up the universal
reference T&& case. This is fine since I guess std::forward and T&& are
used together in 99% of the cases.
What I needed to understand was what happens if you have a template that
takes T and not T&&.
template<typename T>
class SomeClass
{
public:
SomeClass( T t )
{
someFnc( std::forward<T>( t ) );
}
}
int main()
{
int i = 10;
SomeClass<int&> sc( i );
return 0;
}
My conclusion was (I hope it's correct?) that std::forward always pass
along lvalue references and move everything else.
Thanks for a very well written book!
Best regards,
Daniel