Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ error about returning a function

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;
}

Name: Anonymous 2012-04-10 18:58

In the world today, there are 6,800 different dialects or languages that might gain political recognition as independent linguistic groups. The 200 or so existing states should each, on average, be cut into 34 pieces.

Name: Anonymous 2012-04-10 18:59

Should U.S. give its niggers separate state, deport them or just exterminate?

Name: Anonymous 2012-04-10 19:02

Basques, Bretons, Punjabis, Québecois, and Scots -- all should demand independence!

Name: Anonymous 2012-04-10 22:01

Member functions (such as functors) have a this pointer parameter, but regular functions do not.

Name: Anonymous 2012-04-11 4:24

If I had to guess, it's because in operator FunctionPointer() you cannot simply cast a std::function<T> to T (perhaps operator T() is not implemented in the std::function<T> class). I am not so familiar with Microsoft's implementation of C++0x.

Name: bampu pantsu 2012-05-29 4:19

bampu pantsu

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List