0

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

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


但我#include <algorithm>在我的 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>
//--------------------------------------------------------------------------

我的 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");
        }

}

这很奇怪,因为我在同一个程序中使用了诸如 ,std::set_union()之类的功能std::set_intersection()std::set_difference()并且一切正常,直到std::any_of.

抱歉英语不好。

4

1 回答 1

3

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

std::set_union, std::set_intersection, 和std::set_difference不是 c++11 功能,这就是它们起作用的原因。

于 2015-04-29T17:47:34.967 回答