By trying to solve this problem, something made me wonder. Consider the following code:
template <typename T>
struct foo
{
foo(T const& x) : data(x) {}
T data;
};
It seems that I can construct an object of type foo<T const&>
without error, the hypothetical T const& const&
being understood as T const&
.
It seems also that this is called reference collapsing, but I never heard this term before (see comments in the linked question).
Is this widespread? Is this standard?
See Question&Answers more detail:os