문제

I have the following code:

@interface Model ()
{
    //...
    std::function<bool(CGFloat, CGFloat)> greaterThan;
    std::function<bool(CGFloat, CGFloat)> lesserThan;

    //...
}
@end

Everything worked fine in my original project. I just created a new project, and dragged and dropped the files between the two, and in the new project I have the following errors for the above two lines:

No type named 'function' in namespace 'std'

I don't know what the problem is - The files are .mm , why can't it find function in the names space std ?

도움이 되었습니까?

해결책

Add #include <functional> to the top of your code.

Also remember to use -std=c++0x (or equivalent) in your compiler parameters; this will enable C++11 standard which is required for std::function.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top