Topic: Member function templates of non-template classes
Author: gordo@texas.nynexst.com (Gordon J. Tyler)
Date: 28 Feb 1995 22:12:18 GMT Raw View
Has the ANSI committee accepted member function templates of
non-template classes?
I seem to remember reading somewhere that it was initially thought
that problems would arise from supporting this feature, but after
further study, they were going to accept it. What's the status?
For those who see no use for this feature, here is an example:
---WITHOUT FEATURE---
class Field {
string _buffer;
public:
set(int value);
set(long value);
set(const string& value);
};
class Window {
NamedList<Field> _list;
public:
setField(const string& name, int value);
setField(const string& name, long value);
setField(const string& name, const string& value);
};
---WITH FEATURE---
class Field {
string _buffer;
public:
set(int value);
set(long value);
set(const string& value);
};
class Window {
NamedList<Field> _list;
public:
template<class T> setField(const string& name, const T& value);
};
--Gordie.
--------------------------------------------------------
Gordon Tyler NYNEX Science and Technology
gordo@nynexst.com Room T1-A
voice: (914) 644-2053 400 Westchester Avenue
fax: (914) 644-2153 White Plains, NY 10604
--------------------------------------------------------
"That's not a bug, it's just a hidden feature"
Author: vandevod@pleiades.cs.rpi.edu (David Vandevoorde)
Date: 1 Mar 1995 02:11:52 GMT Raw View
In article <3j0742$8fh@news.nynexst.com>,
Gordon J. Tyler <gordo@texas.nynexst.com> wrote:
>Has the ANSI committee accepted member function templates of
>non-template classes?
I believe so. For non-virtual member functions only.
>
>I seem to remember reading somewhere that it was initially thought
>that problems would arise from supporting this feature, but after
>further study, they were going to accept it. What's the status?
It's not so simple to handle virtual member templates because if the
"virtual call" is implemented through an indirection through a table
(and all implementations I've heard of do that), the table size would
become unpredictable (as would the required offsets in that table).
So, yes, for non-virtual members it is allowed.
Anyone knows a compiler that supports this?
Daveed
>--------------------------------------------------------
> Gordon Tyler NYNEX Science and Technology
> gordo@nynexst.com Room T1-A
> voice: (914) 644-2053 400 Westchester Avenue
> fax: (914) 644-2153 White Plains, NY 10604
>--------------------------------------------------------
> "That's not a bug, it's just a hidden feature"
>
>
Author: ncm@netcom.com (Nathan Myers)
Date: Wed, 1 Mar 1995 02:29:47 GMT Raw View
In article <3j0742$8fh@news.nynexst.com>,
Gordon J. Tyler <gordo@texas.nynexst.com> wrote:
>Has the ANSI committee accepted member function templates of
>non-template classes?
>
>I seem to remember reading somewhere that it was initially thought
>that problems would arise from supporting this feature, but after
>further study, they were going to accept it. What's the status?
Member templates have been in the WP since November '93.
Some vendors had not noticed (!) and raised a ruckus (TM) when
they did notice, saying they didn't know how to implement them
fully. We may see them restricted at the March/Austin meeting,
but they will almost certainly not be removed (not least because
the standard library uses them).
Nathan Myers
myersn@roguewave.com
Author: jason@cygnus.com (Jason Merrill)
Date: 01 Mar 1995 01:33:01 GMT Raw View
>>>>> Gordon J Tyler <gordo@texas.nynexst.com> writes:
> Has the ANSI committee accepted member function templates of
> non-template classes?
Yes, so long as they are non-virtual.
Jason