Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

uncalled class template members??

11 views
Skip to first unread message

Atman Binstock

unread,
Mar 30, 1995, 3:00:00 AM3/30/95
to

Hi,
Could someone tell me what the current draft standard says
about uncalled class template members? Need they be checked before
allowing instantiation of the class? For example, if Vector<T>::sort()
uses operator<(const T&, const T&), can you make a Vector<X>, where X
does not support operator<, if Vector<X>::sort() is never called?

Thanks,
Atman Binstock


Fergus Henderson

unread,
Apr 2, 1995, 4:00:00 AM4/2/95
to
a...@panix.com (Atman Binstock) writes:

> Could someone tell me what the current draft standard says
>about uncalled class template members? Need they be checked before
>allowing instantiation of the class?

No. In fact the implementation _must not_ check them (other than
syntax checking).

>For example, if Vector<T>::sort()
>uses operator<(const T&, const T&), can you make a Vector<X>, where X
>does not support operator<, if Vector<X>::sort() is never called?

Yes, you can.

--
Fergus Henderson - f...@munta.cs.mu.oz.au

John Max Skaller

unread,
Apr 3, 1995, 3:00:00 AM4/3/95
to
In article <3lf4gd$k...@panix.com>, Atman Binstock <a...@panix.com> wrote:
>
>Hi,

> Could someone tell me what the current draft standard says
>about uncalled class template members? Need they be checked before
>allowing instantiation of the class? For example, if Vector<T>::sort()
>uses operator<(const T&, const T&), can you make a Vector<X>, where X
>does not support operator<, if Vector<X>::sort() is never called?

Yes, you are supposed to be able to provided
Vector<X>::sort() is not _used_. That includes calling it,
but if it is virtual it is also considered "used".

Note quite a few compilers do not yet provide this
functionality.


--
JOHN (MAX) SKALLER, INTERNET:max...@suphys.physics.su.oz.au
Maxtal Pty Ltd,
81A Glebe Point Rd, GLEBE Mem: SA IT/9/22,SC22/WG21
NSW 2037, AUSTRALIA Phone: 61-2-566-2189

Thomas Holaday,COMM

unread,
Apr 4, 1995, 3:00:00 AM4/4/95
to
In article 27...@mulga.cs.mu.OZ.AU, f...@munta.cs.mu.OZ.AU (Fergus Henderson) writes:

>a...@panix.com (Atman Binstock) writes:
>
>> Could someone tell me what the current draft standard says
>>about uncalled class template members?
>
>No. In fact the implementation _must not_ check them (other than
>syntax checking).
>

The draft standard seems to have it both ways for uncalled virtual methods:

An implementation shall not instantiate a function or a class that
does not require instantiation. However, virtual functions can be
instantiated for implementation purposes.

I'd read that as saying a compliant implementation can reject a class
with a problematical yet uncalled member function if that function is
virtual.


---
~THol()

Thomas Holaday
holaday...@jpmorgan.com
tl...@ibm.net
7040...@compuserve.com

Tony Cook

unread,
Apr 4, 1995, 3:00:00 AM4/4/95
to
John Max Skaller (max...@Physics.usyd.edu.au) wrote:
: In article <3lf4gd$k...@panix.com>, Atman Binstock <a...@panix.com> wrote:
: > Could someone tell me what the current draft standard says
: >about uncalled class template members? Need they be checked before
: >allowing instantiation of the class? For example, if Vector<T>::sort()
: >uses operator<(const T&, const T&), can you make a Vector<X>, where X
: >does not support operator<, if Vector<X>::sort() is never called?

: Yes, you are supposed to be able to provided
: Vector<X>::sort() is not _used_. That includes calling it,
: but if it is virtual it is also considered "used".

What if you explicitly instantiate it?
// fuzzy on syntax here..
template Vector<X>;
--
Tony Cook - to...@online.tmx.com.au
10023...@compuserve.com

0 new messages