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 6252041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:43:33+00:00 2026-05-24T13:43:33+00:00

This is a mouthful, so here’s a piece of code as an example: template<typename

  • 0

This is a mouthful, so here’s a piece of code as an example:

template<typename T>
void foo(const T& a, typename T::value_type::value_type b) { }

std::vector<std::vector<int>> vec;
foo(vec, 4); // Error, can't specialize function template

This compiles and runs correctly using gcc. It doesn’t compile using Visual Studio 2010, for the reason commented above. However, if the final value_type is prefixed with the template keyword, it will compile and run correctly. I have a few guesses as to why, but can’t find the relevant section of the standard.

template<typename T>
void foo(const T& a, typename T::value_type::template value_type b) { }

std::vector<std::vector<int>> vec;
foo(vec, 4); // Compiles and runs correctly with Visual Studio 2010

I’m aware that the above usage of template is a Visual Studio extension, but what does the standard say about using types like this? Is gcc’s acceptance of the code also an extension, or is this a deficiency on Visual Studio’s part?

  • 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-24T13:43:34+00:00Added an answer on May 24, 2026 at 1:43 pm

    This is absolutely a deficiency on VC++ 2010’s part – std::vector<int>::value_type is a type, not a template, and should not be decorated as such. In fact, use of that syntax in this context should cause a compiler error.

    Supporting evidence is that the following does compile (as it should):

    #include <vector>
    
    template<typename T>
    void foo(T const& a)
    {
        typename T::value_type::value_type bar = a.at(0).at(0);
    }
    
    int main()
    {
        std::vector<std::vector<int>> vec;
        foo(vec);
    }
    

    and the following doesn’t (as it shouldn’t):

    template<typename T>
    void foo(T const& a)
    {
        typename T::value_type::template value_type bar = a.at(0).at(0);
    }
    

    The resulting error being

    error C2903: 'value_type' : symbol is neither a class template nor a function template

    I recommend opening a bug report on MS Connect and posting the link back here so we can vote it up.

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

Sidebar

Related Questions

For me, this is quite a mouthful of code. I understand the pieces of
This is an example of the code am using. I use a modified version
:) My question is quite a mouthful. This is a WinForms question : I'm
this is my first question in here, and I would like to ask if
This is my code: <CheckBox android:id=@+id/sprint_checkbox android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/sprint_game /> <CheckBox android:id=@+id/marathon_checkbox android:layout_width=fill_parent android:layout_height=wrap_content
This code below allows me to find the word error in all my files
This is my sample code: SPWeb web = SPContext.Current.Web SPList list = web.Lists[TestList]; try
This code won't compile because there is an illegal reference to a static field.
This is my code: $.ajax({ url: someUrl, type: PUT, data: { id: id, message:
This silverlight code throws an error Cannot invoke a non-delegate type var WshShell =

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.