我正在尝试将 EASTL 用于我正在处理的项目,它无法编译,我能找到的唯一错误来自它的“EASTL/initializer_list.h”,我正在使用此文件的最新版本。出现的 2 个错误是 C2953 和另一个告诉我查看其定义的错误。EASTL 会自动禁用包含此文件时出现的所有警告,甚至有自己的定义以在其文件中使用。唯一的问题是这包含了文件的 Windows 版本,它仍然会导致错误,即使它应该包含就好了?我正在使用 C++14,我的平台工具集是 v142(Visual Studio 2019),我的 Windows SDK 版本是 10.0;我知道据说要更新我已经完成的“EA_HAVE_CPP11_INITIALIZER_LIST 定义”,所以不应该
这是导致错误的代码:
#if defined(EA_HAVE_CPP11_INITIALIZER_LIST) // If the compiler can generate calls to std::initializer_list...
// The initializer_list type must be declared in the std namespace, as that's the
// namespace the compiler uses when generating code to use it.
EA_DISABLE_ALL_VC_WARNINGS()
#include <initializer_list>
EA_RESTORE_ALL_VC_WARNINGS()
#else
// If you get an error here about initializer_list being already defined, then the EA_HAVE_CPP11_INITIALIZER_LIST define from <EABase/eahave.h> needs to be updated.
namespace std
{
// See the C++11 Standard, section 18.9.
template<class E>
class initializer_list
{
public:
typedef E value_type;
typedef const E& reference;
typedef const E& const_reference;
typedef size_t size_type;
typedef const E* iterator; // Must be const, as initializer_list (and its mpArray) is an immutable temp object.
typedef const E* const_iterator;
private:
iterator mpArray;
size_type mArraySize;
// This constructor is private, but the C++ compiler has the ability to call it, as per the C++11 Standard.
initializer_list(const_iterator pArray, size_type arraySize)
: mpArray(pArray), mArraySize(arraySize) { }
public:
initializer_list() EA_NOEXCEPT // EA_NOEXCEPT requires a recent version of EABase.
: mpArray(NULL), mArraySize(0) { }
size_type size() const EA_NOEXCEPT { return mArraySize; }
const_iterator begin() const EA_NOEXCEPT { return mpArray; } // Must be const_iterator, as initializer_list (and its mpArray) is an immutable temp object.
const_iterator end() const EA_NOEXCEPT { return mpArray + mArraySize; }
};
}
#endif
我尝试让它同时使用该类的 std 版本和该类的 EA 版本,这两者都会导致相同的错误(C2953)。感谢任何帮助,因为我希望能够尽快编译它!