🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Template instantiation question

#1872
From: Wil Evers
Date: Wed, 30 Aug 1995 08:25
47 lines
2057 bytes
In article <41vlmh$kat@engnews2.Eng.Sun.COM>, stephen.clamage@Eng.sun.com (Steve
Clamage) wrote:

> In article i3d@engnews2.Eng.Sun.COM, "bnr (n.) postmaster" <postmast@bnr.ca>
writes:

[snip]

> >
> >template<class T>
> >class MyPtrClass {
> >  T* ptr;
> >public:
> >   // etc...
> >   T* operator->(void) { return(ptr); }
> >   // etc...
> >};
> >
> >
> >This causes problems on some compilers (e.g. Borland C++ v4.5) if type
> >'T' is does not have "operator->" defined, even if I never call the
> >"operator->" defined above. 
> 
> I believe the template declaration is valid only when T is a class type.
> Section 13.5.6 "Class Member Access" places requirements on the return type
> of operator->. When the class template is processed, the declaration would be
> invalid even if you never use the function.
> 
> Possibly someone could point out something in the draft which makes the
> template valid as long is operator-> is never actually referenced.

Does anyone know why the restriction 'operator->() must return a class type' was
included in the standard, even when its result is never used to access a class
member? After all, this rule makes it impossible to write a smart pointer
template pointing to a type T that works both when T is a class type and when T
is something else.
If there is no clear rationale for this restriction, I think it should be
dropped.

	[I think it *has* been dropped. -fjh (moderator).]

- Wil Evers (wil@ittpub.nl)
 
---
[ 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. ]
Technical Details
Message-ID: <9508300803.AA05597@sun4nl.NL.net>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 30 Aug 95 08:25:09 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
Return-Path: <daemon@ncar.UCAR.EDU>
X-Original-Date: Wed, 30 Aug 1995 10:03:39 +0200
Message-ID: <9508300803.AA05597@sun4nl.NL.net>
Subject: Re: Template instantiation question
From: Wil Evers <wil@ittpub.nl>