为什么我得到“非聚合不能用初始化器列表初始化” [英] why am I getting "non-aggregate cannot be initialized with initializer list"

查看:281
本文介绍了为什么我得到“非聚合不能用初始化器列表初始化”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

In Xcode I have C++ Language Dialect set to "C++0x [-std=c++0x]" and C++ Standard Library set to "libc++ LLVM C++ Standard library with C++0X Support"

我需要设置别的东西吗?

Do I need to set something else?

推荐答案

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

EDIT 10/2013: this answer is really old, Apple Clang does support this now.

C ++ 11 Initializer从Clang 3.0开始还不支持初始化列表

C++11 Initializer Lists are not yet supported as of Clang 3.0

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

See the implementation status here: Clang C++11 implementation status

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

(Your syntax looks correct if only the compiler supported this feature)

这篇关于为什么我得到“非聚合不能用初始化器列表初始化”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆