🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3214

The type of the this pointer

#3214
From: Dawn Koffman
Date: Sat, 03 Feb 1996 03:31
39 lines
2341 bytes
Question 1 

The ARM says:

    "The type of this in a member function of class X is X *const unless 
     the member function is declared const or volatile; in those cases, 
     the type of this is const X *const and volatile X *const, respectively."

9.4.2 of the 4/95 draft standard says:

    "The type of this in a member function of class X is X*.  If the member
     function is declared const, the type of this is const X*, if the member
     function is declared volatile, the type of this is volatile X*, and
     if the member function is declared const volatile, the type of this 
     is const volatile X*."

Why has the type of this changed from X* const to X*, and from const X* const 
to const X*?

Question 2

9.4.2 of the draft standard goes on to say:

    "In a const member function, the object for which the function is called 
     is accessed through a const access path; therefore, a const member 
     function shall not modify the object and its non-static data members."

This section of the draft standard doesn't say anything to indicate that 
mutable data members may be modified inside const member functions.  However,
a simple example in D&E (page 287) seems to show that they may.  

Where in the draft standard is there an indication that mutable data members 
_may_ be modified inside const member functions?  And, assuming they may, 
what mechanism allows this, given that in a const member function the object 
is accessed through a const access path?
---
[ 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. ]
Technical Details
Message-ID: <199602022342.SAA23370@cnj.digex.net>
Path: arc1-ca.pugleaf.net!fido.asd.sgi.com!austern

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!fido.asd.sgi.com!austern
From: Dawn Koffman <dkoffman@cnj.digex.net>
Newsgroups: comp.std.c++
Subject: The type of the this pointer
Date: 02 Feb 1996 19:31:30 PST
Organization: -
Approved: austern@isolde.mti.sgi.com
Message-ID: <199602022342.SAA23370@cnj.digex.net>
NNTP-Posting-Host: isolde.mti.sgi.com
X-Original-Date: Fri, 2 Feb 1996 18:42:41 -0500
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBVAwUBMRLXOky4NqrwXLNJAQGKbAH9GlifM5Vad4vt4CljR6/FEnjmzE222HiB
 iHqNwgp+zZMx0tGmhaQxH5GkM0nAbqgr+9oHPPl2aN/eG5RPCSAf3A==
 =6gy9
Originator: austern@isolde.mti.sgi.com