1

Topic: Why it is forbidden to create independently std:: initializer_list

Hello. Under the standard the user cannot create objects of type std:: initializer_list differently except as by default. What for it is made?, For example, it would be convenient to me to return std:: initializer_list from a mathematical vector or any other container storing elements in sequence: math:: vector4 <float> mv = {0, 0, 0, 0}; std:: vector <float> cv = mv.slice (); For example, so. VS2013 allows to bypass the standard, there the designer on a range is opened. But so not everywhere

2

Re: Why it is forbidden to create independently std:: initializer_list

Went: W> Under the standard the user cannot create objects of type std:: initializer_list differently except as by default. They can be initialized through braced-init-list. Actually, std:: initializer_list also has been added in language for the sake of conversion possibility braced-init-list to a certain object with which it is possible to work as with sequence of elements, and this piece is not intended for any other purposes.

3

Re: Why it is forbidden to create independently std:: initializer_list

Hello, N I., you wrote: NI> They can be initialized through braced-init-list. I in course. NI> and this piece is not intended for any other purposes. Here also it would be desirable to understand - why? In the same place primitive transparent structure, I do not think that it is threatened with any changes in the future

4

Re: Why it is forbidden to create independently std:: initializer_list

I think not to fix its binary representation and to leave possibility to optimize in a place. It, by the way, one of few things in STL which demands compiler support. Hello, Went, you wrote: W> Hello. Under the standard the user cannot create objects of type std:: initializer_list differently except as by default. What for it is made?

5

Re: Why it is forbidden to create independently std:: initializer_list

Hello, swingus, you wrote: S> I Think not to fix its binary representation and to leave possibility to optimize in a place. It, by the way, one of few things in STL which demands compiler support. I desperately search for an example on which adding the open designer on begin and end killed any optimization, and I find nothing. As functions, their returning, are opened. STL in  stores the beginning and the end, in XCode - the beginning and length, but it does not influence the interface of the user in any way.

6

Re: Why it is forbidden to create independently std:: initializer_list

Went: NI>> and this piece is not intended for any other purposes. W> here also it would be desirable to understand - why? It would be logical to ask a question why to it followed fulfill any other functions. W> in the same place primitive transparent structure, I do not think that it is threatened with any changes in the future Important not of what this "the primitive structure" consists, and with its what magic allocates the compiler. Being initialized through braced-init-list, std:: initializer_list supervises lifetime of a temporal array, the size (an amount of elements) which it is known at a compilation stage. You yet did not explain that you are is specific want to receive from std:: initializer_list. How you were going to flood there something and what the compiler should do with it? Array cells where they will be stored also who will form by whom will be engaged in their destruction?

7

Re: Why it is forbidden to create independently std:: initializer_list

Hello, N I., you wrote: NI> it would be logical to ask a question why to it followed fulfill any other functions. It is possible to paraphrase and so. NI> of what this "the primitive structure" consists, and is important not with its what magic allocates the compiler. Being initialized through braced-init-list, std:: initializer_list supervises lifetime of a temporal array, the size (an amount of elements) which it is known at a compilation stage. You yet did not explain that you are is specific want to receive from std:: initializer_list. How you were going to flood there something and what the compiler should do with it? Array cells where they will be stored also who will form by whom will be engaged in their destruction? That is you state, what std:: initializer_list in the certain implicit image supervises lifetime of objects to which he refers? There is a method it to check up?

8

Re: Why it is forbidden to create independently std:: initializer_list

9

Re: Why it is forbidden to create independently std:: initializer_list

Hello, N. I. Thanks for the information, but, probably, my level of knowledge of language are not enough to understand than it hinders to open at sheet the designer under two pointers For example, the link too prolongs lifetime of objects, but it does not hinder to create to my the reference somehow, though from the pointer, though from other link, though from function

10

Re: Why it is forbidden to create independently std:: initializer_list

Went: W> but, probably, my level of knowledge of language it is not enough to understand than it hinders to open at sheet the designer under two pointers You and did not explain that you want to have from it. At std:: initializer_list there is a specific application, and what for to fasten to it any designers with pointers, not clearly. If the analog array_view you can look for ready implementation is necessary to you or write the.

11

Re: Why it is forbidden to create independently std:: initializer_list

Hello, N I., you wrote: NI> If the analog array_view you can look for ready implementation is necessary to you or write the. Yes, so, it was necessary  the. Than it is bad? Well, all standard containers have a designer on std:: initializer_list. And on my bicycle - is not present. To make explicit or implicit coercion coercion of my bicycle to std:: initializer_list I too , therefore to write down beautifully in one line something like: void foo (const std::vector<int>& i) {} void bar (const math::vector3<float>& v) {foo (v.slice ());//Function-member slice ostensibly returns array_view <float>, but at std:: vector there is no suitable designer sad} it does not turn out.

12

Re: Why it is forbidden to create independently std:: initializer_list

Went: W> to Make explicit or implicit coercion of my bicycle to std:: initializer_list I too I can not But it is possible to add a conversion function immediately to the container if strongly it would be desirable. W> therefore to write down beautifully in one line something like: W> void foo (const std::vector<int>& i) {} And why the parameter foo has type const std::vector<int>&, instead of any array_view <const int>?

13

Re: Why it is forbidden to create independently std:: initializer_list

Hello, N I., you wrote: NI> But it is possible to add a conversion function immediately to the container if strongly it would be desirable. Strongly it would be desirable, that objects more low level (the link to the certain arranged array of objects) have not been stuck in implementation on higher (was specific a vector, a line, an array, etc.). And so it is necessary or to cause or write explicitly external functions operator of coercion in the interface or any proxies-objects to get. NI> and why the parameter foo has type const std::vector<int>&, instead of any array_view <const int>? It is a synthetic example.

14

Re: Why it is forbidden to create independently std:: initializer_list

Hello, Went, you wrote: W> Hello. Under the standard the user cannot create objects of type std:: initializer_list differently except as by default. What for it is made?, For example, it would be convenient to me to return std:: initializer_list from a mathematical vector or any other container storing elements in sequence Can auto helps? As far as I understand, auto v = {...} gives std:: initializer_list.

15

Re: Why it is forbidden to create independently std:: initializer_list

Hello, Basil2, you wrote: B> Can auto helps? As far as I understand, auto v = {...} gives std:: initializer_list. In my opinion, we each other do not understand. I need to return std:: initializer_list under the data available for me, for example, on a vector. struct vector2f {std:: initializer_list <float> slice () {//What to write here? How helps auto?} float x, y;} If I will write return {x, y} it will be  copies of the data which, besides, will be already dead on an output from function. And it would be desirable something like such (taking into account alignment) return std:: initializer_list <float> (&x, &x + 2);//Explicit construction at first and to the end of the data

16

Re: Why it is forbidden to create independently std:: initializer_list

Hello, Went, you wrote: W> In my opinion, we each other do not understand. I need to return std:: initializer_list under the data available for me, for example, on a vector. Try auto slice () {return {x, y}} If does not drive, try to read more in detail Mejersa Modern a C ++. There it is described how to remove conversion in std:: initializer_list. Means, somewhere it so is returned, hence it is possible