For_each () in C ++

I compiled my code on two different machines, which I thought were identical. However, one compiles without problems, and the other gives the following error.

LogEventReader.cpp(320) : error C3861: 'for_each': identifier not found, even with argument-dependent lookup

Relevant Code:

#include <algorithm> 
...
for_each(messages.begin(), messages.end(), processXMLMessage);

Any ideas what could be the problem? TIA.

+3
source share
2 answers

The probable problem is that the first compiler wants using namespace std;before allowing the use of undecorated identifiers from this namespace (for example for_each), and the second one is excessively permissive and does not require it.

, , , , , std::for_each (using std::for_each;) (using namespace std;) - () , , - ;-).

+10

std::for_each(). , .

+12

Source: https://habr.com/ru/post/1714520/


All Articles