Boost logo

Boost :

Subject: Re: [boost] [result_of] fails with clan (C++11)
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2012-11-28 19:31:18


On Wed, Nov 28, 2012 at 1:25 PM, Oliver Kowalke <oliver.kowalke_at_[hidden]>wrote:

> 2012/11/28 Oliver Kowalke <oliver.kowalke_at_[hidden]>
>
> >
> > > You are asking result_of to compute the result of calling a unary
> > > function that takes an X& with zero arguments. That's nonsensical. If
> > > you intend to call it with an X&, then ask it what the result is when
> > > called with an X&:
> > >
> > > boost::result_of< Fn(X&) >::type
> > >
> > > This should correctly report void regardless of whether result_of uses
> > > decltype or the TR1 result_of protocol.
> >
> > OK, I got it.
> > It's strange that clang 3.2 (c++11), gcc, ontel and msvc compile the code
> > without errors on Loinux and Windows.
> >
> I thought I could the problem can be solved like the following code, but
> it does not compile for gcc (c++0x):
>
> #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
> template< typename Fn >
> void g( BOOST_RV_REF( Fn) ) {
> typedef typename remove_reference< Fn >::type Y;
> BOOST_STATIC_ASSERT((
> is_same< void, typename result_of< Y( X &) >::type >::value));
> }
> #else
> ...
> #endif
>
> g() should be callable with function pointers, copyable and moveable-only
> functors (signatue void( X&)).
>
> Again - the original code works for gcc, intel, msvc and clang (Linux) and
> fails for clang on MacOS X.
>

It would help if you gave a complete, compilable example and the error
you're getting.

- Jeff


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