[v3 PATCH] Implement LWG 2825, LWG 2756 breaks class template argument deduction for optional.

Tim Song t.canens.cpp@gmail.com
Tue Jan 31 06:37:00 GMT 2017


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.



More information about the Gcc-patches mailing list