#include <iostream>
usingnamespace std;
template<typename Integrand>
double integrate(Integrand const& i,int N){
//calculate the integral using operator() on i
}
class A{
public:
A(){
class One{
public:
doubleoperator()(int i){
return 1;
}
}one;
cout << "integrate 1 from 0 to 10 gives " << integrate(one,10) << ", right?" << endl;
}
};
int main(){
A a;
return 0;
}
On compilation g++ gives
main.cpp: In constructor ‘A::A()’:
main.cpp:18: error: no matching function for call to ‘integrate(A::A()::One&, int)’
I read, that local classes were a topic of change in 2003.
By the way, it is possible to define class One outside of A() and then everything's fine.
But my question is: Is it simply impossible to use a local class as a template parameter or is there a keyword or a slight change which would make it work?