Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling function with parenthesis around its name using C++

Tags:

c++

I found code in boost similar to:

class A
{
    stats stat;
public:
    int min() const{ return (stat.min)(); }
};

...

int stats::min()
{
...
}

Why are parenthesis here? I know that it can be used for "most vexing parse" and to prohibit ADL. But maybe something else? Thanks in advance!

like image 383
user2319183 Avatar asked Nov 06 '13 11:11

user2319183


1 Answers

It's done because windows.h (Windows platform) has #defines for both min and max. See here for more info: How to tame the Windows headers (useful defines)? and https://stackoverflow.com/a/13420838/297451

like image 61
Jon Avatar answered Oct 20 '22 17:10

Jon