Boost logo

Boost :

From: helmut.zeisel_at_[hidden]
Date: 2001-10-09 02:33:07

--- In boost_at_y..., Darin Adler <darin_at_b...> wrote:
> on 10/8/01 9:13 AM, williamkempf_at_h... at williamkempf_at_h...
> wrote:
> >> 2) For some reason, "thrd" is parsed as a function pointer,
> >> not as an object of class boost::thread.
> >
> > Interesting. Any standards experts wich to comment on whether
> > is a VC++ bug or a mistake in the example code? I can change the
> > code to use two lines in the documentation.
> It's a mistake in the example code. This is one of the most common
> mistakes. The rule is sometimes summarized as, "if it looks like a
> declaration, it is a function declaration". Reams have been written
> this idiosyncrasy of C++ syntax.

GCC 3.0.1 reacts in a similar way as VC++.

In addition, writing

   boost::thread thrd=thread_alarm(secs);

gives the error message

"conversion from `thread_alarm'
to non-scalar type `boost::thread' requested"

on GCC 3.0.1 and a similar error message under VC++.

This is in concordance with the interpretation of thrd as
a function pointer when writing

   boost::thread thrd(thread_alarm(secs));

What I do not understand, however, is why
the two-line version

   thread_alarm fct(secs);
   boost::thread thrd(fct);

and the "pointer" version

   boost::thread* thrdp= new boost::thread(thread_alarm(secs));

Why is the conversion from thread_alarm to boost::thread
found in the latter cases?


Boost list run by bdawes at, gregod at, cpdaniel at, john at