Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 183923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:12:06+00:00 2026-05-11T15:12:06+00:00

In MSVC 2008, I have the following code: class Foo { // Be a

  • 0

In MSVC 2008, I have the following code:

class Foo {   //  Be a little smarter about deriving the vertex type, to save the user some typing.   template<typename Vertex> inline void drawVertices(     Elements vCount, RenPrim primitiveType, PixMaterial *mtl, Vertex const *vertices)   {     this->drawVertices(vCount, primitiveType, mtl, vertices, Vertex::VertexType);   }    virtual void drawVertices(     Elements vCount,     RenPrim primitiveType,     PixMaterial *mtl,     void const *vertices,     uint vertexType) = 0; }; 

I use it something like:

struct RenFlexibleVertexPc {   enum { VertexType = RenVbufVertexComponentsPc };   float x;   float y;   float z;   GraVideoRgba8 c; // Video format, not external! };     PixMaterial *material;   struct Pc : RenFlexibleVertexPc           {             void set(Triple t, uint cl) { x = (float)t.x_; y = (float)t.y_; z = (float)t.z_; c = cl; }           } vpc[4];   ...   Foo *renderer;   renderer->drawVertices(4, RenPrimTriangleFan, material, vpc); 

This works fine in MSVC 2008 SP1. However, GCC (3.4 and 4.1,2) throws a ‘no matching function for call to function’ error, apparently not seeing the template when there is a non-template function with more arguments.

Is GCC broken, or is my code broken, and if so, why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:12:06+00:00Added an answer on May 11, 2026 at 3:12 pm

    There is no problem with overloading or inheritance:

    #include <iostream> #include <memory>  namespace {     struct A {         virtual void f()         {             std::cout<<'inside A's f()\n';         }          template <typename T> void f(T t)         {             std::cout<<T::i<<'\t';             this->f();         }     };      struct B : A {         void f()         {             std::cout<<'hello\t';             A::f();         }     };      struct C {         static const unsigned int i = 5;     };      struct D {         enum { i = 6 };     }; }  int main() {     std::auto_ptr<A> b(new B());     b->f(C());     b->f(D()); } 

    Works correctly. On the other hand, the smallest example I can find that exhibits your problem does not have inheritance or overloading:

    #include <iostream>  namespace {     struct A {         template<class C> void print(C c)         {             c.print();         }     }; }  int main() {     struct B {         void print()         {             std::cout << 'whee!\n';         }     };      A a;     B b;     a.print(b); } 

    Note that if struct B is defined in a namespace (whether it’s an unnamed namespace, or a completely different namespace, or the global namespace) instead of inside main() that this compiles without error.

    I don’t know enough of the standard to say if this is a bug, but it appears to be one. I’ve gone ahead and reported it to the GCC bug database.


    And here’s your answer from the GCC developers (from the link above): ‘Local classes cannot be template arguments.’

    So the code is broken. Not that it’s a bad idea. In fact, C++0x removes this restriction.

    I noticed the line

    Note that the code works in GCC if I explicitly cast vpc to (RenFlexibleVertexPc *)

    And since RenFlexibleVertexPc is not a local class this makes sense. However Pc is a local class/struct, so it is not allowed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 102k
  • Answers 103k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer OpenSolaris ships with the open source Xorg & DRI drivers… May 11, 2026 at 8:20 pm
  • Editorial Team
    Editorial Team added an answer I have seen such things come up when doing angle… May 11, 2026 at 8:20 pm
  • Editorial Team
    Editorial Team added an answer Yes, in this case you will have to do the… May 11, 2026 at 8:20 pm

Related Questions

I am having trouble getting my project to link to the Boost (version 1.37.0)
I'm tyring to convert a MSVC project from VS 2005 to VS 2008. It
Since our switch from Visual Studio 6 to Visual Studio 2008, we've been using
I have just installed the Platform SDK for Windows Server 2008 and .NET 3.5
We have many developers here using MSVC 2008 and I want to standardize the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.