This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [v3 PATCH] Implement C++17 string searchers.
- From: Ville Voutilainen <ville dot voutilainen at gmail dot com>
- To: Jonathan Wakely <jwakely at redhat dot com>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 12 Sep 2016 18:55:06 +0300
- Subject: Re: [v3 PATCH] Implement C++17 string searchers.
- Authentication-results: sourceware.org; auth=none
- References: <CAFk2RUbmYXDmdN856fC1gQLQKf9+t+tbs+_WxB=VeeKWiBGMTQ@mail.gmail.com> <20160912104129.GA17165@redhat.com> <CAFk2RUao_bL_oXmEhw=fSJnchKZE=ciDhJMbaCrB_TST_t_Myg@mail.gmail.com> <20160912150648.GB17165@redhat.com>
On 12 September 2016 at 18:49, Jonathan Wakely <jwakely@redhat.com> wrote:
>>> Is there a reason I didn't use an alias template or variable template
>>> here?
>>>
>>> template<typename _Pred>
>>> using __is_std_equal_to = is_same<equal_to<void>, _Pred>;
>>>
>>> That avoids defining a new class template.
>>
>>
>> I don't know whether that's a practical difference, the alias is
>> shorter of course.
>
>
> It's considerably lighter in terms of compilation cost. Defining a new
> primary template adds more overhead than an alias template that uses
> an already defined template.
Sure, I'm wondering how much lighter in practical terms. Let's chalk
this up as an improvement
that we can do once we have the promised better tests. :)
>>>> + return std::make_pair(__first_ret, __second_ret);
>>>
>>>
>>>
>>> This could be simply return { __first_ret, __second_ret };
>>
>>
>> That doesn't mean exactly the same thing. I can potentially concoct
>> evil code for which the result
>> is different with such a return and make_pair.
>
>
> While you certainly know the pair constructors better than I do, I
> don't think you can for a valid iterator type. Please don't waste your
> time trying though :-)
Again, let's do this with better tests at hand. Also, I think it's
reasonable to do a quick walk
over our library and see whether we have unqualified make_pairs and
make_tuples somewhere,
because those are subject to ADL. In this particular case, it may well
be reasonable to just
not use make_pair, but it should be ok for now, as in I will not lose
sleep over it in the short term. :)