The following code does not compile:
#include
#include
struct Foo
{
Foo() { std::cout << \"Foo()\" << std::
While I agree that it's counter-intuitive, the reason is that your copy constructor takes a const Bar&
but bar1
is not const.
http://coliru.stacked-crooked.com/a/2622b4871d6407da
Since the universal reference can bind anything it is chosen over the more restrictive constructor with the const requirement.