user2319183
user2319183

Reputation: 103

Calling function with parenthesis around its name using 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!

Upvotes: 9

Views: 1573

Answers (1)

Jon
Jon

Reputation: 5335

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

Upvotes: 14

Related Questions