Boost logo

Boost Users :

Subject: Re: [Boost-users] [Thread] this_tread::sleep won't compile with gcc, "no match for operator+"
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2011-05-31 12:21:53


Alexey Malakhov <malakhov_at_[hidden]> writes:

> 2011/5/30 Igor R <boost.lists_at_[hidden]>
>
> > Basically, what I'm trying to do is:
> >
> >     using namespace boost::posix_time;
> >     using namespace boost::this_thread;
> >
> >     time_duration td = milliseconds(2000);
> >     sleep(&td);
>
> Just curious: what's the purpose of the ampersand here?
> http://www.boost.org/doc/libs/1_46_1/doc/html/thread/thread_management.html
> #thread.thread_management.this_thread.sleep
>
>
> Igor, thanks for the note. My ampersand came from VS refusing to compile
> otherwise.
> But you're right, semantically it should not be there.
>
> And it's true, in win32 version this_thread::sleep() declaration is
> inline void sleep(TimeDuration const& rel_time)
>         {
>             interruptible_wait(detail::pin_to_zero(rel_time->total_milliseconds
> ()));
>         }

No, it isn't. I don't know where the -> came from, but it's not in the
boost source.

> It's probably not supposed to be like that, but this is the only way it's
> working for me. If anyone could
> come up with a more elegant solution, I'd appreciate it greatly.

Install the latest boost and use sleep(td) on all platforms.

Anthony

-- 
Author of C++ Concurrency in Action     http://www.stdthread.co.uk/book/
just::thread C++0x thread library             http://www.stdthread.co.uk
Just Software Solutions Ltd       http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

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