Topic: Re- Template instantiation


Author: "Bill Gibbons" <bill_gibbons@taligent.com>
Date: 1995/08/30
Raw View
Distribution:
In article <MATT.95Aug30105929@Austern>, clamage@Eng.Sun.COM wrote:

> I did some more digging, and found that the rules for operator-> are
> relaxed for templates. Section 14.3.3, "Instantiation of operator->" says:
>
> "If a template has an operator->, that operator-> can have a return type
that
> cannot be dereferenced by -> as long as that operator-> is neither invoked,
> nor has its address taken, isn't virtual, nor is explicitly instantiated."
>
> So the orginal example, according to the draft standard if not current
> compilers, is allowed.

However, motion 14 at the Monterey meeting relaxed the rules even more.
Here's the text of the proposal, minus wordsmithing details:

   Relax the restriction on the return type of operator->() so that
   checking is performed only for the implicit use in expressions such
   as x->m for both the template and non-template case.

So now operator-> can be declared with any return type (including void),
and it can always be called explicitly (like any other function).  But if
it's called implicitly, the usual type checking rules apply.

That is, if x->m causes operator-> to be called, it's equivalent to

    (x.operator->())->m

with all the associated implications and restrictions.


Bill Gibbons
bgibbons@taligent.com


---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]