|
Boost Users : |
Subject: Re: [Boost-users] Boost.Function compile error
From: Igor R (boost.lists_at_[hidden])
Date: 2013-03-07 07:00:26
>> It's because the compiler threats
>> Bla(id);
>> as:
>> Bla id;
>> as you can see from the errors (MSVC10):
>> error C2371: 'id' : redefinition; different basic types
>> error C2512: 'Bla' : no appropriate default constructor available
>
>
> Yes but which (obscure) c++ rule allows this. My day to day c++ knowledge
> says that () is only used for macro invocations, function declarations,
> function call's and cast operators and none of them seems to be applicable
> here.
I belive this falls under the paragraph 6.8:
"There is an ambiguity in the grammar involving expression-statements
and declarations: An expression-statement with
a function-style explicit type conversion (5.2.3) as its leftmost
subexpression can be indistinguishable from a declaration
where the first declarator starts with a (. In those cases the
statement is a declaration."
While paragraph 5.1 (5) says:
"A parenthesized expression is a primary expression whose type and
value are identical to those of the enclosed expression.
The presence of parentheses does not affect whether the expression is
an lvalue. The parenthesized expression can
be used in exactly the same contexts as those where the enclosed
expression can be used, and with the same meaning,
except as otherwise indicated."
Try the following :)
int (main())
{
}
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