list-initialization Questions

1

Solved

Like the title suggests, I have a short demo program that compiles on with all of those compilers, but core dumps when ran after compiling with gcc 4.8 and gcc 4.9: Any ideas as to why? #include ...
Amaleta asked 7/1, 2014 at 21:36

1

Solved

Here are two ways to initialize a variable in C++11: T a {something}; T a = {something}; I tested these two in all scenarios I could think of and I failed to notice a difference. This answer sug...
Freezedry asked 22/12, 2013 at 19:48

2

Solved

Since C++11, the Standard Library containers and std::string have constructors taking an initializer-list. This constructor takes precedence over other constructors (even, as pointed out by @Johann...
Kendrickkendricks asked 7/11, 2013 at 22:25

1

While I am reading page93 $5.1.2 of the C++11 standard, during which it said it is ellegal for you to use the braced-init-list in this case: auto x=[]{return {1,2}}; //error: a braced-init-list is ...
Toilworn asked 2/8, 2013 at 5:52

2

Solved

GCC's implementation destroys a std::initializer_list array returned from a function at the end of the return full-expression. Is this correct? Both test cases in this program show the destructors ...

3

Solved

Say I have a variable auto x that I want to initialize to 7 using brace initialization, simple: auto x {7}; Except I learned that x is NOT an integer, but an initialization list itself. Why? Is ...
Nadanadab asked 15/5, 2013 at 17:48

1

Solved

I have this code struct A { A(); A(A&); }; struct B { B(const A&); }; void f(A); void f(B); int main() { f(A()); } To my surprise this fails with GCC and Clang. Clang says for e...
Redbreast asked 6/4, 2013 at 15:10

3

Solved

In C and C++, one can initialize arrays and structs using braces: int a[] = {2, 3, 5, 7}; entry e = {"answer", 42}; However, in a talk from 2007, Bjarne mentions that this syntax also works for ...
Whortleberry asked 9/1, 2013 at 9:40

1

Solved

I'm trying to wrap my head around some corner cases with c++11 uniform initialization and I can't figure out why is this: struct Base { int x,y,z; }; struct Derived : Base { }; static_assert (st...

1

Solved

We know that T v(x); is called direct-initialization, while T v = x; is called copy-initialization, meaning that it will construct a temporary T from x that will get copied / moved into v (which is...
Commodity asked 19/11, 2012 at 19:47

2

Solved

struct A { private: int a, b, c; }; int main() { A a1{}; A a2 = {}; return 0; } The code was compiled by VC++ 2012 (with the latest update "Nov 2012 CTP"). I expect a1 and a2 are zero-init...
Dissociation asked 16/11, 2012 at 19:19

2

Is this program legal? struct X { X(const X &); }; struct Y { operator X() const; }; int main() { X{Y{}}; // ?? error } After n2672, and as amended by defect 978, 13.3.3.1 [over.best.ics] ...
Uninstructed asked 1/10, 2012 at 16:59

1

Solved

I'm wondering whether the tuple can be initialized by initializer list (to be more precise - by initializer_list of initializer_lists)? Considering the tuple definition: typedef std::tuple< std...

© 2022 - 2024 — McMap. All rights reserved.