lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] [lmi-commits] master 6335e9a 1/4: Render comprehensible


From: Greg Chicares
Subject: Re: [lmi] [lmi-commits] master 6335e9a 1/4: Render comprehensible
Date: Thu, 26 Jan 2017 10:52:47 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0

On 2017-01-26 02:43, Greg Chicares wrote:
> On 2017-01-26 01:27, Vadim Zeitlin wrote:
>> 
>>  I'm not sure if you find C++11 vararg templates comprehensible...
[...]
>> ... but the functions check1() and check2() could clearly be combined into
>> a single function using them, which would, IMHO, be nicer because these not
>> completely trivial functions seem to be identical otherwise.
>> 
>>  I'm not sure if check0() could be _easily_ folded into the same vararg
>> template however, at least with C++11 (with C++17 and its fold expressions
>> it would be trivial).
> 
> Then I think this could wait for C++17.

No, it turns out to be possible in the 1998 dialect. All we need is
  template<typename T>
  void foo
    (T t
    ,int required_arg_0
    ,char required_arg_1
    ,int optional_arg_0 = 42
    ,...other optional args
    )
because there's only one template parameter.

> OTOH, perhaps check0() might just as well do what the others do,
> and create an 's' which would probably have to equal an (empty) 'c';
> then we could get to one.

In principle, yes. But C++11's std::equal() fails with empty ranges.
C++14 has:

template<typename InputIt1, typename InputIt2>
bool equal( InputIt1 first1, InputIt1 last1,
            InputIt2 first2, InputIt2 last2 );

which might or might not work. However,
  k.empty() || std::equal(c, c + n, s.begin())
is almost good enough for now. I'm working on this now and will
push something soon for your review.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]