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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:12:01+00:00 2026-05-22T23:12:01+00:00

Updated below . The following is the entire code I have in my main.cpp:

  • 0

Updated below.
The following is the entire code I have in my main.cpp:

template<class T>
struct other_traits;

template<class T>
struct some_traits{
    typedef decltype(&T::operator()) Fty;
    typedef typename other_traits<Fty>::type type;
};

int main(){
}

But I get the following errors with Visual Studio 2010 while g++ compiles just fine:

src\main.cpp(9): error C2146: syntax error : missing ‘;’ before identifier ‘type’
–src\main.cpp(10) : see reference to class template instantiation ‘some_traits<T>‘ being compiled
src\main.cpp(9): error C2868: ‘some_traits<T>::type‘ : illegal syntax for using-declaration; expected qualified-name

(I like that last one, total wtf.)

Can I take that as a bug in VC10 or is there any good reason for the early instantiation? Or is it a bug with decltype that makes the compiler think that Fty is not a dependent name?


Update: I tried to cheat the compiler in thinking that Fty is a dependent name using a base class to inherit from:

template<class T>
struct other_traits;

template<class R, class C>
struct other_traits<R (C::*)()>{
    typedef R type;
};

template<class Fty>
struct base_traits{
    typedef typename other_traits<Fty>::type type;
};

template<class T>
struct some_traits
    : public base_traits<decltype(&T::operator())>
{};

But the compiler still tries to instantiate / compile everything on the spot, spewing these errors:

src\main.cpp(13): error C2039: 'type' : is not a member of 'other_traits<T>'
          with
          [
              T=
          ]
          src\main.cpp(19) : see reference to class template instantiation 'base_traits<Fty>' being compiled
          with
          [
              Fty=
          ]
          src\main.cpp(19) : see reference to class template instantiation 'some_traits<T>' being compiled
src\main.cpp(13): error C2146: syntax error : missing ';' before identifier 'type'
src\main.cpp(13): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
src\main.cpp(13): error C2602: 'base_traits<Fty>::type' is not a member of a base class of 'base_traits<Fty>'
          with
          [
              Fty=
          ]
          src\main.cpp(13) : see declaration of 'base_traits<Fty>::type'
          with
          [
              Fty=
          ]
src\main.cpp(13): error C2868: 'base_traits<Fty>::type' : illegal syntax for using-declaration; expected qualified-name
          with
          [
              Fty=
          ]

Note that the template parameters are empty. Any ideas?

  • 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-22T23:12:02+00:00Added an answer on May 22, 2026 at 11:12 pm

    It seems to be a Bug (if there is not special flag set as mentioned below).
    Following is an excerpt from Oracle website for C++ templates:

    7.2.2

    The ISO C++ Standard permits
    developers to write template classes
    for which all members may not be
    legal
    with a given template
    argument. As long as the illegal
    members are not instantiated
    , the
    program is still well formed. The ISO
    C++ Standard Library uses this
    technique. However, the
    -template=wholeclass option instantiates all members, and hence
    cannot be used with such template
    classes when instantiated with the
    problematic template arguments.

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

Sidebar

Related Questions

I have a form with the following HTML below: <form id=course_edit_form name=course_form action=/courses/save method=post>
Update: Solved, with code I got it working, see my answer below for the
Got the simplified array working see below Following up on the complicated array to
ORIGINAL (see UPDATED QUESTION below) I am designing a new laboratory database that tests
Code The following code calculates the slope and intercept for a linear regression against
Running the following query in SQL Server Management Studio gives the error below. update
( Updated a little ) I'm not very experienced with internationalization using PHP, it
Just updated build server with rc0 and surprise no chiron. Wondering how you package
Here is the updated question: the current query is doing something like: $sql1 =
We've just updated ASP.NET from Preview 3 to Preview 5 and we've run into

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.