Name: Anonymous 2012-04-10 17:53
Sup /prog/
Can someone explain why I'm getting this error from VS2010?
main.cpp(14): error C2091: function returns function
Why can I not return this fucntion pointer, and how can I change my code so that I can?
Heres my code:
template<typename FunctionPointer>
class FunctionTest
{
public:
typedef typename std::function<FunctionPointer> Function;
private:
const Function function;
public:
FunctionTest(const FunctionPointer& functor)
: function(functor)
{
}
operator FunctionPointer()
{
return (FunctionPointer)(function);
}
};
int test(int x, int y)
{
return x+y;
}
int main()
{
FunctionTest<int(int,int)> x(test);
std::cout<<x(5,6)<<"\n";
system("pause");
return 0;
}
Can someone explain why I'm getting this error from VS2010?
main.cpp(14): error C2091: function returns function
Why can I not return this fucntion pointer, and how can I change my code so that I can?
Heres my code:
template<typename FunctionPointer>
class FunctionTest
{
public:
typedef typename std::function<FunctionPointer> Function;
private:
const Function function;
public:
FunctionTest(const FunctionPointer& functor)
: function(functor)
{
}
operator FunctionPointer()
{
return (FunctionPointer)(function);
}
};
int test(int x, int y)
{
return x+y;
}
int main()
{
FunctionTest<int(int,int)> x(test);
std::cout<<x(5,6)<<"\n";
system("pause");
return 0;
}