|
Boost : |
From: Chris Byrne (chris_at_[hidden])
Date: 2003-10-02 22:55:34
On Thu, 02 Oct 2003 10:01:49 +0200
Daniel Spangenberg <dsp_at_[hidden]> wrote:
>
> The rule is: "Anything what can be a declaration is a declaration!"
>
> > Futher more, how can an instantiated variable idx actually be used
> > in a function declaration?
>
> Function parameter identifier in function declarations never interact
> with other valid names outside
> the scope of the function declaration, because they are local to scope
> of the function prototype. Otherwise you would change the meaning of
> function declarations in situations where you introduce further names.
>
> Hope that helps,
>
> Daniel Spangenberg
>
>
With a bit more investigation I discovered that:
boost::thread thrd2(MyThread);
boost::thread thrd2(MyThread idx);
boost::thread thrd2(MyThread(idx));
all result in the same definition. So with a bit of a read through Stroustrup I finally came across A.5 which has the very rule you just quoted at me ;-)
"if it could possibly be interpreted as a declaration, it is a declaration"
char(x); // declaration of a char called x
So that line:
boost::thread thrd2(MyThread(idx));
pseudo like:
funcret functypename(parm(parmname));
Which makes sense now, so thanks for that.
The last problem I have however, is should an interface exist where this confusion can easily be made?
Wouldn't it be better to provide a member function to create a thread instead of using the constructor?
- Chris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk