Search code examples
c++stdc++builderstl-algorithmc++builder-6

E2316 'any_of' is not a member of 'std'


So I'm trying to use std::any_of() function, but C++ Builder 6 says that there is an error:

[C++ Error] Unit1.cpp(93): E2316 'any_of' is not a member of 'std'


But I have #include <algorithm> in my Unit1.h

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <set>
#include <algorithm>    // std::set_union, std::sort, etc
#include <vector>       // std::vector
#include <math.h>
//--------------------------------------------------------------------------

My Unit1.cpp:

void __fastcall TForm1::Button7Click(TObject *Sender)
{
        int el = StrToInt(LabeledEdit1->Text);
        if ( std::any_of(A.begin(), A.end(), (*MyIteratorA==el)) ){
                ShowMessage("true");
        }else{
                ShowMessage("false");
        }

}

It's weird, because I'm using such functions as std::set_union(), std::set_intersection(), std::set_difference() in the same programm and everything worked fine untill std::any_of.

Sorry for bad english.


Solution

  • C++ Builder 32-bit is not C++11 compliant. For all of the c++11 features you need to use the 64-bit version.

    std::set_union, std::set_intersection, and std::set_difference are not c++11 features, which is why they work.