Mercurial > octave
changeset 22083:c88d2ecb721c
octave_value_list: template constructor to accept any sequence container.
* libinterp/octave-value/ovl.h: we support construct from a Array<octave_value>
and std::initializer_list<octave_value>. This expands to other sequence
containers such as std::vector and std::list or anything that has a similar
interface. Frendlier to standard library.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Sun, 10 Jul 2016 12:36:55 +0100 |
parents | beac7654c86d |
children | 79ee6df71b51 |
files | libinterp/octave-value/ovl.h |
diffstat | 1 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave-value/ovl.h Sun Jul 10 12:28:38 2016 +0100 +++ b/libinterp/octave-value/ovl.h Sun Jul 10 12:36:55 2016 +0100 @@ -54,10 +54,8 @@ octave_value_list (const octave_value& tc) : data (dim_vector (1, 1), tc), names () { } - octave_value_list (const Array<octave_value>& d) - : data (d.as_row ()), names () { } - - octave_value_list (const std::initializer_list<octave_value>& args) + template<template <typename...> class OV_Container> + octave_value_list (const OV_Container<octave_value>& args) : data (dim_vector (1, args.size ())), names () { octave_idx_type i = 0; @@ -65,6 +63,10 @@ data(i++) = x; } + // Shold probably be handled as a specialization of the Container template. + octave_value_list (const Array<octave_value>& d) + : data (d.as_row ()), names () { } + octave_value_list (const Cell& tc) : data (tc.as_row ()), names () { } @@ -176,6 +178,7 @@ }; + //! Construct an octave_value_list with less typing. /*! Historically, this made it easier to create an octave_value_list