- Home /
- Visual Studio /
Reported by Beat Bolli Apr 05, 2017 at 09:32 PM Visual Studio 2017 version 15.1windows 10.0C++
The attached source code demonstrates the regression, or I don't understand C++ any more...
This syntax of the constructor (parentheses vs. braces) determines whether operator() is found correctly. The explicit .operator() call also works. The commented out call compiles fine on GNU g++, so I think the syntax is fine. It constructs a temporary object and immediately calls its operator().
It seems that the attachment isn't visible, so I'll put it here:
enum LOG_LEVEL {
LL_FATAL, LL_ERROR, LL_WARNING, LL_INFO
};
class MainLog {
public:
explicit MainLog(const char* ctx) : context(ctx) {}
void operator()(LOG_LEVEL ll, const char* msgFormat, ...) {}
private:
const char* context;
};
void main() {
// error C2661 : 'MainLog::MainLog' : no overloaded function takes 3 arguments
// MainLog(__func__)(LL_INFO, "This is a %s", "test");
// works:
MainLog(__func__).operator()(LL_INFO, "This is a %s", "test");
// works:
MainLog{ __func__ }(LL_INFO, "This is a %s", "test");
}
Empty C++ console application project
1
Solution
VS2017 option "/Zi" should generate vc150.pdb instead of vc140.pdb
0
Solution
vcvarsall.bat from VC++ 2015 v140 toolset does not work
3
Solution
visual c++ - windows runtime component
1
Solution
VS2017 C++ build/clean fails
4
Solution
无法找到文件kernel32.lib->Unable to find file Kernel32.lib
1
Solution
Microsoft.VisualC.CppCodeGenerator missing keyword(s)
0
Solution
The code link of Error List points wrong documentation
0
Solution