Boost logo

Boost :

Subject: [boost] [type_erasure] compile error with gcc 4.8
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2013-05-22 09:07:04

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.


#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:
    //has_post<void(boost::function<void()>), const
    has_post<void(boost::function<void()>&&), const
>{} ;
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;};
    return 0;

Boost list run by bdawes at, gregod at, cpdaniel at, john at