list-initialization

list-initialization

文章 0 浏览 3

c++ 11-从aggrrgate的汇总列表限制

on cppreference.com的此页面我阅读了以下内容: 如果t是汇总类,而支撑式列表有一个 相同或派生类型的元素(可能是CV合格), 对象是从该元素初始化…

就是爱搞怪 2025-02-12 03:23:12 1 0

即使使用允许Shortlambdasonasinglineleline,Short Lambda被Clang-Format分开

我有此代码块: int main() { SomeType something1( [](const Input& i) -> Output { return Output {1, 2}; }, [](const Input& i) -> Output { retu…

∝单色的世界 2025-02-10 13:45:12 1 0

他的C++ 20撑杆初始化后兼容失败的原因是什么?

我发现了一个有趣的情况,其中有效(?)C ++ 17代码在使用C ++ 20进行编译时失败。最简单的再现是具有明确默认构造函数的结构。在C ++ 17上,此代码…

月光色 2025-02-05 14:19:20 1 0

了解编译器如何在初始化内使用普通{}清单

考虑以下玩具代码: class Y { public: Y(int, int) { cout << "Y ctor\n"; } }; class X { public: //X(initializer_list) { cout << "init\n"; } //…

肥爪爪 2025-02-04 11:08:13 3 0

在C中给出一个非初始化的数组值

我的问题非常基本,但我找不到任何内容。 我有一系列的指针。我想将其分配 mat* quickAccessMatrices[6] = {&MAT_A,&MAT_B,&MAT_C,&MAT_D,&MAT_E,&MAT…

云雾 2025-01-30 14:56:26 3 0

尝试从数组读取文件名时出现错误

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. 这个问题是由类错字或无法再现的问题…

2025-01-27 04:23:54 3 0

模板结构的支撑封闭的初始化列表

#include #include #include #include using namespace std; template struct item_t { array weight = {0}; }; int main(void) { vector> items; ite…

吻安 2025-01-26 20:59:31 3 0

字典初始化python的seg断层

因此,我正在研究一个处理大量车辆和这些车辆之间的变速器的项目。我有一个工作代码,可以很好地适用于少量车辆,但是当我开始使用大量〜500辆车时,…

软甜啾 2025-01-25 23:51:06 4 0

如何在c&#x2b;&#x2b;像一个实际的数组?

免责声明 美好的一天,我是新手程序员,所以如果我有任何明显的错误,请不要判断我。 我有一个看起来像这样的代码。 class Book{ public: string auth…

千柳 2025-01-25 17:43:57 3 0

直接启动是否等于直接列表限制?

我有以下示例: struct S{ int x, y; } S s1{1}; // direct-initialization or direct-list-initialization ? S s2{1, 2}; // direct-initialization …

初心未许 2025-01-23 18:57:18 3 0

如何在 C++ 中支撑自定义类的初始化向量?

拥有此简单的代码: #include #include #include class Person{ public: Person(std::string const& name) : name(name) {} std::string const& getNa…

ゞ记忆︶ㄣ 2025-01-20 02:56:24 3 0

构造函数的第一个版本和第二个版本有什么区别

第一个 1 版本正确。但是,为什么代码不使用第二个 2 版本? #include #include #include using namespace std; template class Synchronized { publi…

幸福%小乖 2025-01-17 19:22:53 3 0

为什么结构数组不需要大括号初始化?

这段代码: #include struct { int i; const char* str; } ar[] = { 1,"asd", //should be {1, "asd"}, 2, "qwe", //should be {2, "qwe"}, 3, "poi" …

忆沫 2025-01-14 15:00:57 4 0

如何初始化成员初始值设定项列表中的数组成员

class C { public: C() : arr({1,2,3}) //doesn't compile {} /* C() : arr{1,2,3} //doesn't compile either {} */ private: int arr[3]; }; 我相信…

月光色 2024-09-30 01:45:28 14 0
更多

推荐作者

梦断已成空

文章 0 评论 0

瞎闹

文章 0 评论 0

寄意

文章 0 评论 0

似梦非梦

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文