Re: Constrained Forwarding(R-Value Reference)
On 15 mar, 14:50, grizl...@yandex.ru ("Grizlyk") wrote:
Pedro Lamar?o wrote:
lt& doesn't mean "reference to copyable", it means "reference to
lvalue".
As i can understand, temporary can not be assigned to "non-const reference"
only due to the reference can be passed out of the temporary scope and
writing into non-existing stack of the terminated function for some people
looks like more dangerous when reading from the non-existing memory or
calling functions with random entry point, that can be done with the
temporary assigned to "const reference".
This may have been the rationale for for the current rules for
reference binding.
The rationale being accepted the rules were set.
The current working paper has new syntax for references.
References declared with this new syntax have binding new rules.
These new rules, governing this new syntax, do allow for temporaries
to be bound to references.
It has been found that these new rules satisfy the desire for
expressing Moveable.
You seem to disagree and we seem to not understand why.
and b is of type bar, and bar is not Copyable.
In spite the "bar" is undeclared, i trust you.
My mistake, a copy and paste error.
I meant for "bar" to be "resource".
I'll try again.
You are telling me that "T const&" requires T to be Copyable.
If this is true, how can the following code be valid?
class resource {
public:
resource ();
private:
resource (resource const&);
resource& operator= (resource const&);
};
template <typename T>
void
foo (T const& t) { }
void
f () {
resource r1;
foo(r1);
}
--
Pedro Lamar?o
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]