3 ms·
> I do not think they had this kind of usage in mind when they allowed it I think they did based on 8.5.3 which has this example: struct A { }; struct B :
by MaulingMonkey 13y ago
> I do not think they had this kind of usage in mind when they allowed it
I think they did based on 8.5.3 which has this example:
struct A { };
struct B : public A { } b;
extern B f();
const A& rca = f(); // Either bound to the A sub-object of the B rvalue,
// or the entire B object is copied and the reference
// is bound to the A sub-object of the copy
As well as 12.2 para 5:
class C {
// ...
public:
C();
C(int);
friend C operator+(const C&, const C&);
˜C();
};
C obj1;
const C& cr = C(16)+C(23);
C obj2;
In the C++ standard which talks about the temporary bound to cr existing for the duration of the entire program? Moreover, why would a rule for const references be specifically needed to handle foo( bar() );, but no equivalent rule for bar().foo(); which handles an implicit non-const pointer?