草庐IT

c++ - 为什么我得到 "non-aggregate cannot be initialized with initializer list"

coder 2023-05-02 原文

std::map<std::string, int> m = {
    {"Marc G.", 123},
    {"Zulija N.", 456},
    {"John D.", 369}
};

在 Xcode 中,我将 C++ 语言方言设置为“C++0x [-std=c++0x]”,并将 C++ 标准库设置为“支持 C++0X 的 libc++ LLVM C++ 标准库”

我需要设置其他东西吗?

最佳答案

EDIT 10/2013:这个答案真的很老了,Apple Clang 现在确实支持这个。

自 Clang 3.0 起尚不支持 C++11 初始化列表

在此处查看实现状态:Clang C++11 implementation status

(如果只有编译器支持此功能,您的语法看起来是正确的)

关于c++ - 为什么我得到 "non-aggregate cannot be initialized with initializer list",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8920699/

有关c++ - 为什么我得到 "non-aggregate cannot be initialized with initializer list"的更多相关文章

随机推荐