This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [v3 PATCH] Implement LWG 2825, LWG 2756 breaks class template argument deduction for optional.
- From: Tim Song <t dot canens dot cpp at gmail dot com>
- To: Jason Merrill <jason at redhat dot com>, Ville Voutilainen <ville dot voutilainen at gmail dot com>
- Cc: Jonathan Wakely <jwakely at redhat dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 31 Jan 2017 10:25:42 +0800
- Subject: Re: [v3 PATCH] Implement LWG 2825, LWG 2756 breaks class template argument deduction for optional.
- Authentication-results: sourceware.org; auth=none
- References: <CAFk2RUa1gqaEgxUpcByBBCorL0Y7K81M+Sbi=q_eUdf1XXu52A@mail.gmail.com> <20170130132821.GR3093@redhat.com> <20170130133614.GS3093@redhat.com> <CAPQZVxsik2B8v5cmw9LXjWJqhA8X-Yp9DUHLSfHNr9bF+CDY6A@mail.gmail.com> <CAFk2RUZLcrLvpLqMLP==pS07Bfj7v6==vYsxwFRWHTDRUk0brA@mail.gmail.com> <CAFk2RUYt8cO-hyrCwe_BQJw4hoWwWsUWDU+aOc86g=ebJDEt+Q@mail.gmail.com>
On Tue, Jan 31, 2017 at 8:48 AM Ville Voutilainen
<ville.voutilainen@gmail.com> wrote:
>
> On 31 January 2017 at 00:41, Ville Voutilainen
> <ville.voutilainen@gmail.com> wrote:
>
> I don't actually need to constrain it, I could just add a guide like
>
> template <typename _Tp> optional(optional<_Tp>) -> optional<_Tp>;
>
> However, I'm not convinced I need to. The preference to an explicit
> guide is, at least based
> on that paper, a tie-breaker rule. If the copy/move constructors are
> better matches than the guide,
> those should be picked over a guide. Jason?
Yes, but they are not "better matches". They are equally good matches
after deduction and substitution. The mechanism that selects
template<class T> void f(const optional<T>&) over template<class T>
void f(T) given an optional<int> argument is partial ordering, and
that's the last tiebreaker in the list, *after* the implicit/explicit
guide tiebreaker.