[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: error: no matching constructor for initialization of 'string_vector'
From: |
Ben Abbott |
Subject: |
Re: error: no matching constructor for initialization of 'string_vector' |
Date: |
Thu, 25 Aug 2016 20:43:19 -0400 |
> \On Aug 25, 2016, at 9:01 AM, Carnë Draug <address@hidden> wrote:
>
> On 25 August 2016 at 13:23, Ben Abbott <address@hidden> wrote:
>>> On Aug 25, 2016, at 07:09, Carnë Draug <address@hidden> wrote:
>>>
>>>> On 25 August 2016 at 01:27, Ben Abbott <address@hidden> wrote:
>>>> Carne,
>>>>
>>>> The chagneset below is giving me an error.
>>>>
>>>> http://hg.savannah.gnu.org/hgweb/octave/rev/f38e81248556
>>>>
>>>> libinterp/octave-value/ov-classdef.cc:2275:17: error: no matching
>>>> constructor for initialization of 'string_vector'
>>>> string_vector v (names);
>>>> ^ ~~~~~
>>>>
>>>> I’m using Apple’s llvm/clang
>>>>
>>>> Apple LLVM version 7.3.0 (clang-703.0.31)
>>>>
>>>> Ben
>>>
>>> I have no idea why your compiler is failing to find the constructor.
>>> Is it because it can't decide which constructor to use? Which ones
>>> is it undecided about?
>>>
>>> Carnë
>>
>> I'm embarrassed to say that I don't know what a constructor is. I'll do a
>> quick study.
>>
>> Can give me some background on what your patch is doing?
>>
>
> A constructor is a class method that constructs an object of that class.
> The name of those methods is the same as the class name.
>
> For example, in Octave, these are constructors:
>
> p = inputParser (); # construct inputParser object
> a = audiorecorder (fs, nbits, nchannels); # construct audiorecorder object
>
> The change I made replaced the code that was manually constructing
> a string_vector, with a string_vector constructor that does the same
> thing.
>
> In languages like C++, a class can have more than one constructor, even
> with same number of arguments. The compiler looks at the type of the
> arguments and picks the constructor that fits the best. Sometimes there's
> more than one constructor that fits, hence my question about what
> constructors is clang considering (gcc error messages mention the
> different possibilities so I'm expcting clang to do something similar).
>
> In the case of the string_vector class, these are the constructors available:
>
> string_vector (void)
>
> string_vector (octave_idx_type n)
>
> string_vector (const char *s)
>
> string_vector (const std::string &s)
>
> string_vector (const string_vector &s)
>
> template <template <typename...> class String_Container>
> string_vector (const String_Container<std::string> &lst)
>
> string_vector (const Array<std::string> &s)
>
> string_vector (const char *const *s)
>
> string_vector (const char *const *s, octave_idx_type n)
>
> In the change that's causing issues for clang, the argument is a
> std::set<std::string> so I would expect it to use the templated
> constructor for String_Container<std::string>.
If I’m following … might clang require an explicit constructor for
std::set<std::string>?
Ben