Local class as template parameter - still impossible?

Hello!

I'm trying to build a method which integrates a function which is given as a functor.
Here is my minimal code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
using namespace 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:
               double operator()(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?

I'm curious about your answers.

Robert
I just don't think g++ compiler will allow it (and if there was an option to allow it then I didn't find it).

MSVC will allow it both in VC2008 and VC2010


EDIT:
I believe it will be allowed in C++0x
Last edited on
Ok,

Thank You very much!

Unfortunately MSVC is no option to me. But I'm looking forward to C++0x.
Topic archived. No new replies allowed.