E2316 'any_of'不是 'std' 的成员

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

本文关键字:std 成员 不是 any E2316 of      更新时间:2023-10-16

所以我正在尝试使用std::any_of()函数,但是C++生成器 6 说有一个错误:

[C++错误] Unit1.cpp(93): E2316 "any_of"不是"std"的成员


但我的单元中有#include <algorithm> 1.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>
//--------------------------------------------------------------------------

我的单位1.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");
        }
}

这很奇怪,因为我在同一个程序中使用了 std::set_union()std::set_intersection()std::set_difference() 等函数,直到 std::any_of 年一切正常。

对不起,英语不好。

C++ Builder 32 位不符合 C++11。对于所有 c++11 功能,您需要使用 64 位版本。

std::set_unionstd::set_intersectionstd::set_difference 不是 C++11 特性,这就是它们工作的原因。