Article View: comp.std.c++
Article #658Operator -> cannot return non-class types?
From: Daniel Larsson
Date: Wed, 11 Nov 1992 09:23
Date: Wed, 11 Nov 1992 09:23
34 lines
1470 bytes
1470 bytes
Yesterday, I tried HP's new C++ compiler (3.0) and templates for the first
time. To my surprise, I noticed that operator -> can only return the following
three types:
- a pointer to a class,
- a class, or
- a reference to a class.
This means I cannot do simple things like:
template< class T >
class OffsetPtr
{
public:
OffsetPtr();
OffsetPtr( T* );
...
T* operator ->();
...
};
OffsetPtr<char> ptrToString;
What is the rationale behind this restriction? I couldn't find anything in
C++PL 2nd ed. that mentions this restriction, although I didn't look too hard.
-- Daniel
--
---------------------------------------------------------------------------
Daniel Larsson Email: dlarsson@aut.abb.se
ABB Automation AB Telefax: +46 21 34 25 25
V{ster}s, Sweden Telephone: +46 21 34 30 29
Technical Details
Message-ID:
<1992Nov11.092316.306@aut.abb.se>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!news2me.EBay.Sun.COM!seven-up.East.Sun.COM!sixgun.East.Sun.COM!sungy!news.Sweden.Sun.COM!swippy!seunet!abbaut!dlarssonShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!news2me.EBay.Sun.COM!seven-up.East.Sun.COM!sixgun.East.Sun.COM!sungy!news.Sweden.Sun.COM!swippy!seunet!abbaut!dlarsson From: dlarsson@aut.abb.se (Daniel Larsson) Newsgroups: comp.std.c++,comp.lang.c++ Subject: Operator -> cannot return non-class types? Summary: HP C++ 3.0 won't allow me to return e.g. char* from operator -> Keywords: HP C++ 3.0, operator -> Message-ID: <1992Nov11.092316.306@aut.abb.se> Date: 11 Nov 92 09:23:16 GMT Organization: ABB Automation AB, Vasteras, Sweden Lines: 34