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

  • SEARCH
  • Home
  • 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 5838043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:25:33+00:00 2026-05-22T11:25:33+00:00

Possible Duplicate: Using template parameters as template parameters Here’s a code snippet of some

  • 0

Possible Duplicate:
Using template parameters as template parameters

Here’s a code snippet of some heavily templated container classes used to bind an arbitrary amount of fields of arbitrary types. A co-worker of mine found that my code didn’t compile under GCC and after much research he found the fix to get it to deduce the templates correctly by adding ::template … Neither of us had ever seen this before and still don’t really know what this is other than something that GCC needs for my code that Visual Studio 2010 does not need.

    template< typename T, int N >
    struct SingleBindMemberStruct
    {
        typedef typename TGenericBindingHandler<T>::BindToUse BindType;
        BindType m_Member;

        template< typename ContainerClass >
        static void AddBinding(CPackedTableDataSpec* spec)
        {
// Perhaps with newer versions of the compilers we can find a syntax that both accept. This is with gcc-4.5 and Visual Studio 2010
#if defined(__GNUC__)
            TGenericBindingHandler<T>::template AddBinding<ContainerClass>(spec, N, &ContainerClass::template SingleBindMemberStruct<T,N>::m_Member);
#else
            TGenericBindingHandler<T>::template AddBinding<ContainerClass>(spec, N, &ContainerClass::SingleBindMemberStruct<T,N>::m_Member);
#endif
        }
    };

Does anyone know syntactically what ::template can or should be used for? If anyone has a snippet from the standard that describes it that would be perfect!

Edit:

Alright so sounds like it is really as simple as helping the compiler determine what is a template and since this is a static function we use the scope resolution operator rather than the dot operator to tell the compiler of the template. So now the only remaining question is why does Visual Studio not need this as well?

  • 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. Editorial Team
    Editorial Team
    2026-05-22T11:25:33+00:00Added an answer on May 22, 2026 at 11:25 am

    It tells the compiler that AddBinding is a template — since the definition of AddBinding is dependent on T, the compiler wouldn’t otherwise know this at the right stage of the compilation process (I’m no expert on the details, but it’s to do with the C++ compilation model AFAIK). By writing template after the ::, you give the compiler information it otherwise wouldn’t have. I guess more specifically, it knows that it’s dealing with a template and not a < operator when it sees < after AddBinding.

    If you want a more detailed answer, you might want to check out C++ Templates: The Complete Guide. (I think it’s available as a PDF if you search Google.)

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

Sidebar

Related Questions

Possible Duplicate: Converting XML to JSON using Python? I'm doing some work on App
Possible Duplicate: using mysql_close() Are mysql_close and pg_close required ? In some script there
Possible Duplicate: trailing return type using decltype with a variadic template function I want
Possible Duplicate: trailing return type using decltype with a variadic template function I'm getting
Possible Duplicate: Using Source Control So, although even here on Stack Overflow are literally
Possible Duplicate: Using ASP.NET Controls without databinding My previous question yielded few results so
Possible Duplicate: Casting vs using the ‘as’ keyword in the CLR Which method is
Possible Duplicate: Converting XML to JSON using Python? I am importing an XML feed
Possible Duplicate: Submit a form using jQuery $('#form') Supposed the jQuery Object of the
Possible Duplicate: Watermarked Textbox for Compact Framework Using Visual Studio 2008 SP1, the latest

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.