|
Boost : |
Subject: Re: [boost] [type_erasure] compile error with gcc 4.8
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2013-05-26 16:42:48
*ping*
> Hi Steven,
>
> the following code used to compile with older gcc versions (I just tried
> with 4.5 and I used the same construct with 4.7) but no more with gcc 4.8,
> but I don't know whether it's a gcc or type_erasure problem (or mine).
> The problem seems to be with rvalue refs. If I use the commented out
> version, it compiles fine on both compilers.
> Any idea?
> If you have no gcc 4.8, I can attach the error.
>
> Thanks,
> Christophe
>
> #include <iostream>
>
> #include <boost/type_erasure/any.hpp>
> #include <boost/type_erasure/builtin.hpp>
> #include <boost/type_erasure/operators.hpp>
> #include <boost/type_erasure/constructible.hpp>
> #include <boost/type_erasure/relaxed.hpp>
> #include <boost/type_erasure/member.hpp>
>
> #include <boost/mpl/vector.hpp>
> #include <boost/function.hpp>
>
> BOOST_TYPE_ERASURE_MEMBER((has_post), post);
>
> struct any_post_concept:
> ::boost::mpl::vector<
> //has_post<void(boost::function<void()>), const
> boost::type_erasure::_self>,
> has_post<void(boost::function<void()>&&), const
> boost::type_erasure::_self>,
> boost::type_erasure::relaxed,
> boost::type_erasure::copy_constructible<>
>>{} ;
> typedef boost::type_erasure::any<any_post_concept> any_post;
>
>
> struct any_impl
> {
> //void post(boost::function<void()> f)const {f();}
> void post(boost::function<void()> && f)const {f();}
> };
>
> int main()
> {
> any_impl s;
> any_post p (s);
> boost::function<void()> f = [](){std::cout << "ok" << std::endl;};
> //p.post(f);
> p.post(std::move(f));
> return 0;
> }
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk