|
Boost : |
Subject: Re: [boost] [config] msvc-14 config changes heads up
From: Billy O'Neal (VC LIBS) (bion_at_[hidden])
Date: 2016-07-05 20:08:49
It is "better" as in it is "what the standard says". In g, f is not a dependent name. That means it gets resolved when the template is parsed, f(double) has been declared.
Billy3
________________________________
From: Boost <boost-bounces_at_[hidden]> on behalf of Gavin Lambert <gavinl_at_[hidden]>
Sent: Tuesday, July 5, 2016 5:07:09 PM
To: boost_at_[hidden]
Subject: Re: [boost] [config] msvc-14 config changes heads up
On 6/07/2016 04:44, Stephan T. Lavavej wrote:
> [Beman Dawes]
>> I'm a bit surprised by the removal of BOOST_NO_TWO_PHASE_NAME_LOOKUP.
>> My understanding, which certainly could be wrong, is that update 3
>> internally is doing some of the preliminary work that will enable
>> two-phase name lookup eventually, but two-phase lookup isn't working yet.
>
> That is correct. Here's proof, with our latest development build:
>
> C:\Temp>type meow.cpp
> #include <stdio.h>
>
> void f(int) {
> puts("Standard two-phase!");
> }
>
> template <typename T> void g(T t) {
> f(t);
> }
>
> void f(double) {
> puts("Microsoft one-phase!");
> }
>
> int main() {
> printf("%02d.%02d.%05d.%02d\n", _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000, _MSC_BUILD);
> g(3.14);
> }
>
> C:\Temp>cl /EHsc /nologo /W4 /MTd meow.cpp && meow
> meow.cpp
> 19.00.24229.00
> Microsoft one-phase!
Out of curiosity, since I presume that the expectation is that a
two-phase compiler would try to call f(int) instead -- why is this
considered better?
I assume it has something to do with the order of the definitions or
with the name "f" technically not depending on the template arguments
(but as a function call does depend on its parameters, and its
parameters are dependent, it seems wiser to treat f as dependent so that
overload resolution can truly work as expected).
In particular, if the compiler did decide to use f(int) instead of
f(double) in the code above, then it would generate a compiler error (or
at least a warning, due to double-to-int being a lossy conversion and
therefore requiring an explicit cast) instead of using the "right"
overload. That's the sort of thing that would make me want to throw
things at the compiler, not something I'd consider a feature.
I must be missing something.
_______________________________________________
Unsubscribe & other changes: https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2flists.boost.org%2fmailman%2flistinfo.cgi%2fboost&data=01%7c01%7cbion%40microsoft.com%7c9eff46a7fe07405b277508d3a53189fc%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=bb5c0HNq4RzbedPA7BHL4gZrpXFIjvJRwAG91fjOPH8%3d
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk