Boost logo

Boost :

Subject: Re: [boost] [type_traits] possible regression on is_function trait
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2012-11-06 13:24:04


Le 06/11/12 09:53, John Maddock a écrit :
>> I don't know if this is a regression on Boost.TypeTraits or if I'm
>> using incorrectly the is_function trait.
>
> Ideally it shouldn't be possible to use it incorrectly, which isn't to
> say that there aren't corner cases...
>
>> John, could you confirm there is a bug in is_function?
>
> If the failure is specific to one test runner, then I suspect a
> compiler bug: do you have a reduced test case I can look at?
>
>
Hi,

I don't reach to isolate the error. The following compiles as expected :(

Best,
Vicente

#define BOOST_THREAD_VERSION 4

#include <boost/thread/future.hpp>
#include <boost/static_assert.hpp>

BOOST_STATIC_ASSERT(boost::is_function<int&>::value == false);

BOOST_STATIC_ASSERT((
     boost::is_function<boost::packaged_task<int()> &>::value == false
));
BOOST_STATIC_ASSERT((
boost::is_function<boost::rv<boost::packaged_task<int()> >&>::value == false
));
BOOST_STATIC_ASSERT((
boost::is_function<boost::rv<boost::rv<boost::packaged_task<int()> >
>&>::value == false
));
BOOST_STATIC_ASSERT((
     boost::is_convertible<
       boost::rv<boost::packaged_task<int()> >&,
       boost::rv<boost::rv<boost::packaged_task<int()> > >&
>::value == false
));
BOOST_STATIC_ASSERT((
     boost::detail::is_convertible_impl<
       boost::rv<boost::packaged_task<int()> >&,
       boost::rv<boost::rv<boost::packaged_task<int()> > >&
>::value == false
));

int h() { return 0; }

struct dummy1;

template <class F>
int apply(F f, typename boost::disable_if_c<
boost::is_convertible<F&,BOOST_THREAD_RV_REF(F)>::value,
     dummy1* >::type=0)
{
   return f();
}

template <class R>
boost::future<R> my_async(R(*f)())
{
   boost::packaged_task<R()> pt( f );

   boost::future<R> ret = pt.get_future();
   boost::thread( boost::move(pt) ).detach();
   return boost::move(ret);
}

int g()
{
   return apply(h) + my_async(h).get();
}


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