On 31 January 2017 at 00:41, Ville Voutilainen <[email protected]> wrote: > On 31 January 2017 at 00:06, Tim Song <[email protected]> wrote: >> On Mon, Jan 30, 2017 at 9:36 PM Jonathan Wakely <[email protected]> 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?
