# HG changeset patch # User Carnë Draug # Date 1470949367 -3600 # Node ID 7a6279f4018feca631328f1c9fea76e9c114a81f # Parent dd0d2a27e5b3685dc311d1dfb767f3347b49d6a2 dim_vector: fix type deduction in constructor with parameter pack (patch #9030) * liboctave/array/dim-vector.h: recent rewrite of the multiple constructor changed rules of implicit conversion if arguments were not octave_idx_type (comment #3 on patch #9030). This is because mixed types between the arguments and parameter pack prevented deduction for the implicit initializer list. Fix it by making it explicit. diff -r dd0d2a27e5b3 -r 7a6279f4018f liboctave/array/dim-vector.h --- a/liboctave/array/dim-vector.h Fri Aug 12 04:52:29 2016 +0100 +++ b/liboctave/array/dim-vector.h Thu Aug 11 22:02:47 2016 +0100 @@ -28,6 +28,7 @@ #include +#include #include #include "lo-error.h" @@ -196,17 +197,19 @@ - a column vector, i.e., assume @f$[N, 1]@f$; - a square matrix, i.e., as is common in Octave interpreter; - support for a 1 dimensional Array (does not exist); + + Using r, c, and lengths... as arguments, allow us to check at compile + time that there's at least 2 dimensions specified, while maintaining + type safety. */ template dim_vector (const octave_idx_type r, const octave_idx_type c, Ints... lengths) : rep (newrep (2 + sizeof... (Ints))) { - // Using r, c, and lengths, makes sure that there's always a min of - // 2 dimensions specified, and that lengths are ints (since otherwise - // they can't form a list. - for (const auto l: {r, c, lengths...}) + std::initializer_list all_lengths = {r, c, lengths...}; + for (const octave_idx_type l: all_lengths) *rep++ = l; - rep -= (2 + sizeof... (Ints)); + rep -= all_lengths.size (); } octave_idx_type& elem (int i)