🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Helmut Jarausch Thu, 08 Feb 1996 18:11
Binding a temperary to a non const ref - status of the rules?
#3304
Author: Helmut Jarausch
Date: Thu, 08 Feb 1996 18:11
42 lines
1915 bytes
Please comment on the following ( I know there is a connection to the
auto_ptr discussion, but I am not quite sure about this).
Thank you very much,
Helmut Jarausch.

========================

Assume

class  Vector { ... }

class Vector_R : public Vector
{ // a smart reference to a Vector using reference counts,
  freeing temp. storage immediately after use
  ...
}

class Matrix
{  // Data stored columnwise
   ...
   
   const Vector_R operator[]( int k ) const;  // return k-th column vector
         Vector_R operator[]( int k );        // return k-th column vector
   ...
}

ostream& operator<<( ostream&, const Vector&);
istream& operator>>( istream&, Vector& );

      Matrix  V;
const Matrix  K;


Now I would like the following behaviour (is this true (or will it be) ? )

cout << V[1] << K[1];   // should be OK
cout >> V[1];           // should be OK  (even no warning)
cout >> K[1];           // should be an ERROR - not only a warning
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy is
  in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads