gpt4 book ai didi

c++ - 在 OS X 10.9.3 上使用 Xcode 5.1.1 编译 unordered_map 失败

转载 作者:行者123 更新时间:2023-11-28 02:44:56 25 4
gpt4 key购买 nike

我正在尝试编译一个最初使用 tr1/unordered_map 的项目。我删除了对 tr1 命名空间的所有引用,现在只使用 unordered_map (例如 #include <tr1/unordered_map> 变为 #include <unordered_map> )。但是,我收到编译错误。配置时:

CXXR is now configured for x86_64-apple-darwin13.2.0
Source directory: .
Installation directory: /Library/Frameworks
C compiler: gcc -g -O2 -fexceptions
Fortran 77 compiler: gfortran -g -O2
C++ compiler: g++ -g -O2 -Wno-attributes -std=c++11
Fortran 90/95 compiler: gfortran -g -O2
Obj-C compiler: gcc -g -O2 -fobjc-exceptions
Interfaces supported: X11, aqua, tcltk
External libraries: readline, ICU
Additional capabilities: PNG, JPEG, TIFF, NLS
CR Options enabled: framework, shared BLAS, R profiling
CXXR Options enabled:
Recommended packages: yes

当我尝试编译项目时遇到错误:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/unordered_map:724:5: error: static_assert failed "Invalid allocator::value_type"
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
Environment.cpp:104:5: note: in instantiation of template class 'std::__1::unordered_map<const CXXR::Symbol *, CXXR::Frame::Binding *, std::__1::hash<const CXXR::Symbol *>,
std::__1::equal_to<const CXXR::Symbol *>, CXXR::Allocator<std::__1::pair<const CXXR::Symbol *, CXXR::Frame::Binding *> > >' requested here
delete s_search_path_cache;

s_search_path_cache定义为:

typedef
std::unordered_map<const Symbol*, Frame::Binding*,
std::hash<const Symbol*>,
std::equal_to<const Symbol*>,
CXXR::Allocator<std::pair<const Symbol*, Frame::Binding*> >
> Cache;

static Cache* s_search_path_cache;

我能够找到针对类似问题 (https://issues.apache.org/ooo/show_bug.cgi?id=124422) 的 Apache OpenOffice 错误报告,但无法使用它来解决我的问题。如果有人有任何想法,我将不胜感激。

最佳答案

您的分配器(第二个)中缺少讨厌的 const:

CXXR::Allocator<std::pair<const Symbol* const, Frame::Binding*> >

关于c++ - 在 OS X 10.9.3 上使用 Xcode 5.1.1 编译 unordered_map 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24745702/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com