Consider following piece of code:
//option no 1
struct foo{
foo(baz &b) : _b(b){}
std::reference_wrapper<baz> _b;
};
//option no 2
struct bar{
bar(std::reference_wrapper<baz> b) : _b(b){}
std::reference_wrapper<baz> _b;
};
I am wondering if there are any practical differences between initializing foo
and bar
. If so, what are the pros and cons of each solution and which should be preferred?