Closed nlappas closed 4 years ago
Hm, I guess Visual Studio doesn't let that degrade to the !
operator on an implicit boolean conversion result? I don't have Visual Studio. A little test with Compiler Explorer and x86-64 MSVC 19 2017 RTW doesn't complain: https://godbolt.org/g/ifxNCb. Can you try the version in the dev-msvc-unary-not-operator
branch?
Wow, thanks for the super fast response!
Yes the new branch works properly
Cool. Now I'm not sure if I want to put the explicit unary operator behind an #ifdef
on the compiler or not.
Can you provide more detailed version information for your compiler? I tried http://webcompiler.cloudapp.net/ with the following code and it compiled fine without the explicit unary operator.
struct foo {
int value;
int threshold;
operator bool ()
{
return value >= threshold;
}
};
int main()
{
foo x {1, 2};
return (!x) ? 0 : -1;
}
The version is reported as Microsoft (R) C/C++ Optimizing Compiler Version 19.11.25547 for x64
I submitted a bug report to the VS team. Will see how that goes.
Cool, looks like you got them to add a bug fix:
Leo Zhang [MSFT] · Apr 18 at 01:56 AM 0 Share
Thank you for your feedback! We have fixed the problem in 15.8 Preview 1 which is an upcoming release. Thank you for helping us build a better Visual Studio!
Hi,
I am trying to compile with a simple
But I get the following error in Visual Studio 2017
Error C2675 unary '!': 'argagg::option_results' does not define this operator or a conversion to a type acceptable to the predefined operator
any ideas?
(Update: In gcc 5.4 it works properly... This is weird)