Talk:cpp/utility/initializer list

std::pair c_arr const { return {&v[0], v.size}; // list-initialization in return statement }

Doesn't this example just call pair constructor, without creating any initializer_list? What type would value_type be?


 * True, this is an example of list-initialization. The author of the example just used that helper function to get some values, not to demonstrate initializer_list. I added a comment to the example, to hopefully make that clearer. --Cubbi 14:45, 5 December 2012 (PST)


 * Shouldn't the first template parameter to std:pair be const T*? 92.22.189.245 01:57, 1 May 2013 (PDT)
 * Yes, that makes more sense. Changed. --Cubbi 03:22, 1 May 2013 (PDT)
 * Should &v[0] be v.data? 67.200.126.4 07:58, 16 September 2014 (PDT)
 * would make sense if could be empty.. I don't think it matters in this case.  is more common since it predates c++11. --Cubbi (talk) 10:28, 16 September 2014 (PDT)

"a braced-init-list is used in list-initialization, including function-call list initialization and assignment expressions"
An std::initializer_list is not automatically created in that scenario. The std::pair example points that out nicely. I recommend to reword that bullet. To something like "a braced-init-list is used as argument in calling an initializer list constructor or a function with a std::initializer_list parameter". 79.218.77.197 17:02, 18 May 2017 (PDT)
 * agreed and updated --Cubbi (talk) 06:33, 19 May 2017 (PDT)