Boost logo

Boost Users :

From: Ben Hutchings (ben.hutchings_at_[hidden])
Date: 2005-01-27 10:00:48


Jeff Garland wrote:
> On Wed, 26 Jan 2005 20:04:57 +0000, Ben Hutchings wrote
>
>>Jeff Garland wrote:
>>
>>>Yeah, you are correct it is treating it as a function declaration. This feel
>>>like a gcc bug to me, but there could be some obscure reason why it's that way
>>>that I'm unaware of.
>>
>><snip>
>>
>>This is correct behaviour. The above declaration declares t2 as a
>>function taking two parameters of type ptime (irrelevantly named
>>min_date_time and max_date_time). Any compiler that doesn't parse
>>it as that is broken.
>
>
> So enlighten me. Why would parenthesis be allowed in the function definition
> / name?

Parentheses are sometimes needed in the middle of declarators (example:
int (*pf)()), and are allowed even if they are not needed (example: int
(i)). That applies even where the names will be ignored, as in the case
of parameter names for a non-defining function declaration. This
surprising behaviour is sometimes called the "most vexing parse".

> Can't say I've ever seen that syntax used before. What's the
> advantage -- I can see the downside.

I wouldn't argue in favour of it.

Ben.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net