www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++.beta - [bug] DMC 8.49 enum lookup through class derived from template parameter

↑ ↓ ← Sean Kelly <sean f4.ca> writes:
I believe this lookup should succeed as it does when C explicitly 
derives from B.


C:\code\src\gen\test>type test.cpp
class B
{
protected:
     enum
     {
         ZERO = 0
     };
};


template<class T>
class C : T
{
public:
     C() : val( ZERO ) {}

private:
     int val;
};


void main()
{
     C<B> d;
}

C:\code\src\gen\test>dmc test.cpp
test.cpp(15) : Error: undefined identifier 'ZERO'
test.cpp(26) : Error: expression expected
Fatal error: premature end of source file
--- errorlevel 1

C:\code\src\gen\test>
Oct 23 2006
↑ ↓ Christof Meerwald <cmeerw web.de> writes:
On Mon, 23 Oct 2006 09:59:32 -0700, Sean Kelly wrote:
 I believe this lookup should succeed as it does when C explicitly 
 derives from B.

No, this is a feature (two-phase name lookup) - you can disable this feature with -Ad though. Christof -- http://cmeerw.org sip:cmeerw at cmeerw.org mailto:cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org
Oct 23 2006
↑ ↓ → Sean Kelly <sean f4.ca> writes:
Christof Meerwald wrote:
 On Mon, 23 Oct 2006 09:59:32 -0700, Sean Kelly wrote:
 I believe this lookup should succeed as it does when C explicitly 
 derives from B.

No, this is a feature (two-phase name lookup) - you can disable this feature with -Ad though.

Oops... my actual code was a tad different than what I posted: template<class T> class B {...}; template<class T> class C : B<T> { ... }; But the dependent name lookup rules still obviously apply. Next time I'll spend more time with the spec rather than testing against other compilers... or at least test against Comeau. Thanks! Sean
Oct 23 2006