|
Boost : |
From: Gennadiy Rozental (gennadiy_at_[hidden])
Date: 2002-10-01 03:19:40
> Difficult but I'll try. Rvalues of non-class types don't have addresses as
> they can live outside the addressable memory (in registers, for example.)
> When a reference is bound to an rvalue, that rvalue may need to be copied
to
> addressable memory. In a context where 'this' is not used, rvalues of
class
> types can live outside addressable memory, too.
Does this mean that if 'this' IS used than compiler is not allowed to put
rvalues of class types outside addressable memory?
> So the compiler in the above is allowed to use the copy constructor to
> create another (addressable) temporary of type 'A' (or 'A const') and bind
> the reference to it, instead of binding directly to 'A()' that may not be
> addressable.
Continue my question: does the following should compile?
class A {
public:
A() {};
int field;
private:
A( A const& );
void operator=( A const& );
};
void foo( A const& a )
{
int i = a.field;
}
void moo()
{
foo( A() );
}
Gennadiy.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk