Prefer user-defined conversions over narrowing conversions and conversions to bool.
References:
http://wg21.link/p0608
Differential D44865
[libc++] Implement P0608R3 - A sane variant converting constructor lichray on Mar 24 2018, 1:24 AM. Authored by
Details
Prefer user-defined conversions over narrowing conversions and conversions to bool. References:
Diff Detail
Event TimelineComment Actions Has this paper been adopted into the standard yet?
Comment Actions No. However, it cleanly passed LEWG for recommending a DR against C++17, so I think we can apply it early, just like we sometimes make changes before filing issues :)
Comment Actions This LGTM. However, we should add tests for const bool and volatile bool before committing. Also I would like @mclow.lists input about applying this DR early since LWG Comment Actions Ping @mclow.lists @EricWF ; the patch still applies, is there any other thing I need to address? Comment Actions A few minor things:
Also, the standard says explicitly, "A variant is permitted to hold the same type more than once, and to hold differently cv-qualified versions of the same type." But currently, that is not allowed — not an issue with this patch, but something that should be fixed.
Comment Actions That's not something I can "fix" in this patch :(
Marshall and me agreed that we are going to apply the paper as a "bugfix." We don't want to make the constructor behave differently under different language versions.
Done.
Comment Actions Even though LWG didn't vote it out as a DR; that's what it is, and I think that we would be doing our users a disservice by not providing this in C++17. Comment Actions The patch looks fine to me, but I think you should consider making a couple of T.fail.cpp tests, and check to make sure you get the "right error".
|
I see no need to stop using operator() in favor of a static function. Is there a reason?
Also this would have to be __test.