On Mon, Jan 30, 2017 at 4:48 PM, Ville Voutilainen
<ville.voutilai...@gmail.com> wrote:
> On 31 January 2017 at 00:41, Ville Voutilainen
> <ville.voutilai...@gmail.com> wrote:
>> On 31 January 2017 at 00:06, Tim Song <t.canens....@gmail.com> wrote:
>>> On Mon, Jan 30, 2017 at 9:36 PM Jonathan Wakely <jwak...@redhat.com> wrote:
>>>>
>>>> On 30/01/17 13:28 +0000, Jonathan Wakely wrote:
>>>> >On 30/01/17 13:47 +0200, Ville Voutilainen wrote:
>>>> >>Tested on Linux-x64.
>>>> >
>>>> >OK, thanks.
>>>>
>>>> To be clear: this isn't approved by LWG yet, but I think we can be a
>>>> bit adventurous with deduction guides and add them for experimental
>>>> C++17 features. Getting more usage experience before we standardise
>>>> these things will be good, and deduction guides are very new and
>>>> untried. If we find problems we can remove them again, and will have
>>>> invaluable feedback for the standards committee.
>>>>
>>>
>>> My brain compiler says that this may cause problems with
>>>
>>> std::optional<int> o1;
>>> std::optional o2 = o1; // wanted optional<int>, deduced 
>>> optional<optional<int>>
>>>
>>> Trunk GCC deduces optional<int>, but I don't think it implements
>>> P0512R0 yet, which prefers explicit guides to implicit ones before
>>> considering partial ordering. This example is very similar to the
>>> example in https://timsong-cpp.github.io/cppwp/over.match.best#1.6.
>>
>>
>> I'll see about constraining the guide tomorrow.
>
> 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?

Currently G++ first tries deduction directly from the intializer like
in a call to a function template; only if that fails does it consider
deduction guides.  How to handle class deduction WRT
implicitly-declared constructors is still very much under discussion.

Jason

Reply via email to