1

I've been experiencing this error for a while now, on every project that I have built with the CryEngine2 SDK in Visual Studio 2013 Professional. Most of the time, I have just edited the function from this:

void CMultipleGrabHandler::Reset()
{
    std::for_each (m_handlers.begin(), m_handlers.end(), std::mem_fun (&CBaseGrabHandler::Reset));

    std::vector <CAnimatedGrabHandler*>::iterator it = m_handlers.begin();
    std::vector <CAnimatedGrabHandler*>::iterator end = m_handlers.end();
    for ( ; it != end; ++it)
        delete *it;

    m_handlers.erase (m_handlers.begin (), m_handlers.end ());
}

to this:

void CMultipleGrabHandler::Reset()
{
}

I know it's not a good approach to the problem, but it got rid of the 'mem_fun' : is not a member of 'std' error.

I am now looking for a solution to overcome this problem, since I have just started working on a new project, where stability is key; it's not good if I remove the body of CMultipleGrabHandler::Reset(), since it could possibly induce crashes in certain situations. I have browsed the internet for a solution to this problem, but I have not found anything (closest thing I found was an explanation of what mem_fun does).

I have tried taking std:: off mem_fun, but I just get an mem_fun is undefined error, suggesting that this isn't exactly the right way to go about mending this error.

The project was originally created in Visual Studio 2005, and was migrated to Visual Studio 2013's format when I first opened the solution. Might this be the cause of the problem? How can it be fixed?

Edit: Added as this also applies to the new VS version.

0

1 Answer 1

4

The function std::mem_fun is defined in the header <functional>.

On some older compilers, you don't necessarily need to #include a standard library header in order to use functions and classes defined in that header, because it might already be included by some other standard library header that you #include. This is not exclusive to VS; it was also true for older gcc versions, like 4.0. Newer compilers are more standard-conforming and will require you to #include the actual headers that define standard library functions and classes.

3
  • 4
    The old vs new compiler thing isn't really true. The standard explicitly says that headers may include other headers. Jul 4, 2014 at 21:08
  • 1
    @JosephMansfield It does say that, but I still think my interpretation is correct (but I'm open to being proven wrong). For example, iostream may include string, but that doesn't permit the implementation to actually make std::string available if you've included iostream but not string in your program.
    – Brian Bi
    Jul 4, 2014 at 21:18
  • 1
    No, your interpretation is incorrect. When the specification says that "a C++ header may include other C++ headers" (N3797 §17.6.5.2[res.on.headers]/1), it is meant literally. So <iostream> may literally include <string>, and including <iostream> may very well cause e.g. std::string to be declared. Nov 24, 2014 at 3:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.