in Education by
#include 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 ::One F > void run(A & a) { T tmp = 0; (a.*F)(tmp); } int main(int argc, char ** argv ) { A a; run(a); run(a); return 0; } Problem lies with syntax of typename Type::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? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
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).

Related questions

0 votes
    Here, the context of polymorphic is expecting 'Derived' from 'Base&. Given class P { }; class Q : ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I have a function value(x) which is overloaded for many types such that: double value(double x) { return x; } double ... [-Wreturn-local-addr] in the following code: Matrix33 m; m...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    #include using namespace std; template class test { T y; public: test(T k) : y(k) {} friend int a(T& x); }; template int a(T& x) { cout...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    #include using namespace std; template class test { T y; public: test(T k) : y(k) {} friend int a(T& x); }; template int a(T& x) { cout...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    #include using namespace std; template class test { T y; public: test(T k) : y(k) {} friend int a(T& x); }; template int a(T& x) { cout...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    // merge.cpp // merges two containers into a third #include #include //for merge() using namespace std; int src1[] = { 2, 3, 4, ... , src1+5, src2, src2+3, dest); for(int j=0; j...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    As far as I know, in gcc you can write something like: #define DBGPRINT(fmt...) printf(fmt); Is ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    _________ require you to pass a function whose argument is a vector of parameters. (a) optimize() (b) ... Debugging of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    I am working on a game in allegro 5 in which I want to create rectangular objects dynamically on screen and make them clickable with mouse ... if ( x >= rect.x && x = rect.y && y...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    The current user defined objects like lists, vectors, etc. is referred to as __________ in the R language. ( ... of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    I am trying to write a C++ class in a separate header and cpp file using VS Code as my IDE with the 'run' and ' ... #include "Fan.h" #include using namespace std; Fan::Fan() { cout...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I am trying to write a C++ class in a separate header and cpp file using VS Code as my IDE with the 'run' and ' ... #include "Fan.h" #include using namespace std; Fan::Fan() { cout...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I'd like to ensure my RAII class is always allocated on the stack. How do I prevent a class from ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I'd like to ensure my RAII class is always allocated on the stack. How do I prevent a class from ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
...