On Mon, Mar 9, 2015 at 3:17 PM, Matthew Fioravante
<
fmatth...@gmail.com> wrote:
>
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3824.htm
>
> It seems that without being able to forward braced initializers this
> solution to "non-type template argument deduction" via a varidic make
> function is incomplete.
>
> struct Point { double x; double y; }
>
> //n3824 forces us to do this:
> auto a = make_array(Point{1.0, 2.0}, Point{3.0, 4.0});
>
> //Should be able to do something like this:
> auto a = make_array<Point>( { 1.0, 2.0 }, { 3.0, 4.0 });
>
The problem of unable to perfect forward braced-init list
is a problem with uniform initialization itself, and applies
to everywhere, not limited to make_array, nor make_*.
If you want to solve it, go solve it.
> Is it really a good
> thing that initializing a C array and initializing a std::array with size
> deduction use different syntax with completely different rules?
Not "completely". While the language can do something
that library cannot, you will always have caveats, in lots
of places. But if we choose not to make a progress, we
are probably having bigger issues.
>
> class A {
> static constexpr auto a = make_array(1, 2, 3);
> };
> constexpr decltype(A::a) A::a; //Ugly, but it works
>
> template <typename T>
> class B {
> static constexpr auto b = make_array(1, 2, 3);
> };
> template <typename T>
> constexpr decltype(B<T>::b) B<T>::b; //This is a compiler error (it works on
> some versions of gcc, doesn't work on clang, and according to standard
> should fail).
>
Sorry I don't know why this doesn't work. More like
clang's problem to me.
> and if another proposal enables auto in template parameters, we can do this:
>
> std::array<auto,[]> = { 1, 2, 3}; //is std::array<int,3>
>
Even with that proposal, it still may not work
because { ... } with auto will very likely be deduced
to std::initializer_list<int>, or simply not supported,
but std::array is required to have no (user-declared)
constructor.
--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD --
http://bit.ly/blog4bsd