Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 03, 2006 [bug] dmc 8.46.2 | ||||
---|---|---|---|---|
| ||||
I think this is a bug: 01:template < class T > class list 02:{ 03: private : 04: T array [ 10 ]; 05: 06: public : 07: void erase ( T *, T* ) {} 08:}; 09: 10: 11:template < class Tp > class my_list : protected list < Tp > 12:{ 13: public : 14: void Erase ( Tp *_i ) { erase ( _i, _i ); } 15:}; 16: 17: 18: 19:int main () 20:{ 21: int i = 0; 22: 23: 24: my_list < int > lst; 25: 26: lst.Erase ( &i ); 27: 28: return ( 0 ); 29:} P:\apk\bugs>dmc tmplnm.cpp tmplnm.cpp(14) : Error: undefined identifier 'erase' --- errorlevel 1 using the -Ad flag makes the error disappear. using Erase ( Tp *_i ) { this -> erase ( _i, _i ); } also make the error disappear. I think the compiler should/must be able to figure out the base class has a member function which exactly fits in here. I might be missing the obvious, than enlight me please. Thanx, Arjan Knepper |
January 04, 2006 Re: [bug] dmc 8.46.2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to arjan | <arjan@ask.me.to> wrote in message news:dpev06$17s6$1@digitaldaemon.com... > I might be missing the obvious, than enlight me please. Welcome to the lovely world of funky name lookup rules for templates. Template classes don't look up names in base class templates. And no, it's not obvious at all. |
January 04, 2006 Re: [bug] dmc 8.46.2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> <arjan@ask.me.to> wrote in message news:dpev06$17s6$1@digitaldaemon.com...
>
>>I might be missing the obvious, than enlight me please.
>
>
> Welcome to the lovely world of funky name lookup rules for templates. Template classes don't look up names in base class templates. And no, it's not obvious at all.
>
>
Your are probably right, but IIRC that was only the case for _non_ type dependant members. In this case the member is type dependant so shouldn't it be found?
Other compilers seems to do the lookup as I expected.
(I don't have the C++ template book from vandevoorde & josuttis around here to look it up)
Thanx,
Arjan
|
January 04, 2006 Re: [bug] dmc 8.46.2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Arjan | "Arjan" <arjan@ask.me> wrote in message news:dpg85l$2f7i$1@digitaldaemon.com... > Walter Bright wrote: >> Welcome to the lovely world of funky name lookup rules for templates. Template classes don't look up names in base class templates. And no, it's not obvious at all. > Your are probably right, but IIRC that was only the case for _non_ type dependant members. In this case the member is type dependant so shouldn't it be found? list<Tp>::erase is type-dependent. See C++98 14.6.2-2 and 14.6.2.1-1. > Other compilers seems to do the lookup as I expected. Comeau gets it right. |
Copyright © 1999-2021 by the D Language Foundation