On Fri, Aug 19, 2016 at 10:58 AM, S.B.
<
i.and.my.li...@gmail.com> wrote:
> However, it's possible to add another overload of `to_array` to enable
> `to_array<int>({ {1}, {2}, {3} })`.
Not possible, because initializer_list's size() is a part
of value, which will not affect std::array's size which
is a part of type.
> After all, `to_array<const int>({ {1},
> {2}, {3} })` is already valid (and returns a std::array<int,3>) using
> std::experimental::fundamentals_v2::to_array.
Not valid.
There is a way to support braced-init. First extend
to_array with rvalue reference, then combine this
with compound literals in C:
auto a7 = to_array((std::pair<int, float>[])
{ { 3, .0f }, { 4, .1f }, { 4, .1e23f } });
Implemented,
https://gist.github.com/lichray/6034753#file-make_array-cc-L169
Tested against gcc and clang.
After all it's non-standard.
--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD --
http://blog.miator.net/