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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:46:30+00:00 2026-05-27T15:46:30+00:00

#include <iostream> struct A { bool f( int a ) { std::cout << int

  • 0
#include <iostream>

struct A
{
    bool f( int a ) { std::cout << "int" << std::endl; return true;};
    bool f( int a, int b ) { std::cout << "two int" << std::endl; return true;};
    bool f( float a ) {std::cout << "float" << std::endl; return true;};
    bool f( float a, float b ) {std::cout << "two float" << std::endl; return true;};
};

template <typename T>
struct Type
{
    typedef bool (A::*One)(T);
    typedef bool (A::*Two)(T, T);
};

template <typename T, typename Type<T>::One F >
void run(A & a)
{
    T tmp = 0;
    (a.*F)(tmp);
}


int main(int argc, char ** argv )
{
    A a;
    run<int, &A::f>(a);
    run<float, &A::f>(a);

    return 0;
}

Problem lies with syntax of typename Type<T>::One F. If I specify the actual method pointer instead of using my typedef from Type it works fine (see here and here).
Is there a way to use those typedefs from Type as template arguments?

  • 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-27T15:46:30+00:00Added an answer on May 27, 2026 at 3:46 pm

    My current guess is that both IBM xlC and Sun CC have bugs.

    The versions which give errors are probably confused by the use of typename in a template argument context but used to indicates that a dependant name is a type instead of introducing a type argument. Note that these compilers aren’t conforming and don’t demand typename to indicates that a dependant name is a type even in other contexts where it is needed (even for Sun CC versions where your code compile).

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

Sidebar

Related Questions

#include <iostream> #include <boost/thread.hpp> using std::endl; using std::cout; using namespace boost; mutex running_mutex; struct
#include stdafx.h #include <iostream> using std::cout; template<class T> class IsPolymorphic { template<class T> struct
#include <iostream> using namespace std; struct testarray{ int element; public: testarray(int a):element(a){} }; class
#include<iostream> using namespace std; struct sample { int data[3][2]; }; struct sample* function() {
For this program #include <iostream> using std::cout; struct C { C() { cout <<
#include <iostream> #include <queue> using namespace std; struct Call { Call( int callNum, long
#include <iostream> using namespace std; struct Node { int item; // storage for the
#include <boost/ptr_container/ptr_vector.hpp> #include <iostream> using namespace std; using namespace boost; struct A { ~A()
I have this code: #include <iostream> #include <functional> struct A { int operator()(int i)
Consider the following code: #include <iostream> #include <memory> #include <vector> using namespace std; struct

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.