Boost logo

Boost :

Subject: Re: [boost] [utility]result_of - erroneous result type from a C++11 lambda
From: Daniel Walker (daniel.j.walker_at_[hidden])
Date: 2013-04-02 20:09:26


On Apr 2, 2013, at 4:57 PM, "Vicente J. Botet Escriba" <vicente.botet_at_[hidden]> wrote:

> Le 02/04/13 20:46, Vicente J. Botet Escriba a écrit :
>> Le 02/04/13 19:42, Evgeny Panasyuk a écrit :
>>> 02.04.2013 21:16, Vicente J. Botet Escriba:
>>>
>>>> Is this a know bug on boost::result_of or gcc compiler?
>>>
>>> Try http://liveworkspace.org/code/J6bEg$0 :
>>>
>>> #define BOOST_THREAD_PROVIDES_FUTURE
>>> #define BOOST_RESULT_OF_USE_DECLTYPE
>>> #include <boost/thread.hpp>
>>>
>>> int main()
>>> {
>>> boost::future<int> f1 =
>>> boost::async( []() -> int {return 123;} );
>>> }
>>> // ___________________________ //
>>>
>>> For additional info refer http://www.boost.org/users/news/a_special_note_for_boost_1_52_0_and_higher.html , http://www.boost.org/doc/libs/1_53_0/libs/utility/utility.htm#result_of
>>>
>> Thanks, this works.
>>
>> Should then the user of Boost.Thread define BOOST_RESULT_OF_USE_DECLTYPE explicitly?
>>
>>
> BTW,
>
> the definition of BOOST_RESULT_OF_USE_DECLTYPE can be done only if BOOST_NO_CXX11_DECLTYPE because otherwise the inclusion of of result_of.hpp generates some compiler errors on compilers not supporting decltype.
>
> #include <boost/config.hpp>
> #if ! defined BOOST_NO_CXX11_DECLTYPE
> #define BOOST_RESULT_OF_USE_DECLTYPE
> #endif
> #include <boost/thread/future.hpp>
>
> Could result_of.hpp undefine BOOST_RESULT_OF_USE_DECLTYPE if BOOST_NO_CXX11_DECLTYPE is defined?

This question has come up in the past. The answer we've arrived at in previous discussions has been that requesting decltype on a compiler that doesn't have decltype is a user error that should result in a compilation failure.

- Daniel


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk