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++ - Explicit template argument specification for member templates

↑ ↓ ← Christof Meerwald <cmeerw web.de> writes:
Here is a test-case:

struct A
{
  template<typename T>
  int f(T t)
  {
    return T::val;
  }

  template<typename T>
  int g()
  {
    return T::val;
  }
};

struct B
{
  static const int val = 0;
};


int main()
{
  A a;
  B b;

  return a.f<B>(b) + a.f<>(b) + a.f(b) + a.g<B>();
  // Error: '(' expected following simple type name
}


bye, Christof

-- 
http://cmeerw.org                                 JID: cmeerw jabber.at
mailto cmeerw at web.de

...and what have you contributed to the Net?
Nov 24 2002
→ "Neo" <newneo2 yahoo.com> writes:
i think that's because extra wrong directed information
it's like u r parametizing the function in advance and parameter in function
may be different and it may create conflict, and hence error is perfectly
right

"Christof Meerwald" <cmeerw web.de> wrote in message
news:arqv16$eqp$1 digitaldaemon.com...
 Here is a test-case:

 struct A
 {
   template<typename T>
   int f(T t)
   {
     return T::val;
   }

   template<typename T>
   int g()
   {
     return T::val;
   }
 };

 struct B
 {
   static const int val = 0;
 };


 int main()
 {
   A a;
   B b;

   return a.f<B>(b) + a.f<>(b) + a.f(b) + a.g<B>();
   // Error: '(' expected following simple type name
 }


 bye, Christof

 --
 http://cmeerw.org                                 JID: cmeerw jabber.at
 mailto cmeerw at web.de

 ...and what have you contributed to the Net?

Nov 28 2002
Christof Meerwald <cmeerw web.de> writes:
Still doesn't work if the program is slightly modified.

On Sun, 24 Nov 2002 16:33:42 +0000 (UTC), Christof Meerwald wrote:
 Here is a test-case:
 
 struct A
 {
   template<typename T>
   int f(T t)
   {
     return T::val;
   }
 
   template<typename T>
   int g()
   {
     return T::val;
   }
 };
 
 struct B
 {
   static const int val = 0;
 };
 
 
 int main()
 {
   A a;
   B b;
 
   return a.f<B>(b) + a.f<>(b) + a.f(b) + a.g<B>();
   // Error: '(' expected following simple type name

int i = a.f<B>(b) + a.f<>(b) + a.f(b) + a.g<B>(); int j = a.f<C>(c) + a.f<>(c) + a.f(c) + a.g<C>(); // Error: 'A::g' is already defined
 }

bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net?
Jan 06 2003
↑ ↓ → Christof Meerwald <cmeerw web.de> writes:
Oops, missed the definition of C:

On Mon, 6 Jan 2003 19:23:56 +0000 (UTC), Christof Meerwald wrote:
 Still doesn't work if the program is slightly modified.
 
 On Sun, 24 Nov 2002 16:33:42 +0000 (UTC), Christof Meerwald wrote:
 Here is a test-case:
 
 struct A
 {
   template<typename T>
   int f(T t)
   {
     return T::val;
   }
 
   template<typename T>
   int g()
   {
     return T::val;
   }
 };
 
 struct B
 {
   static const int val = 0;
 };


struct C { static const int val = 1; };
 int main()
 {
   A a;
   B b;
 
   return a.f<B>(b) + a.f<>(b) + a.f(b) + a.g<B>();
   // Error: '(' expected following simple type name

int i = a.f<B>(b) + a.f<>(b) + a.f(b) + a.g<B>(); int j = a.f<C>(c) + a.f<>(c) + a.f(c) + a.g<C>(); // Error: 'A::g' is already defined
 }


bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net?
Jan 07 2003