c++ - forward-declaring boost.type_erasure reference type -


i using boost.type_erasure in codebase. far experience, given enables, has been good.

i want able forward-declare " type-erased reference type" api. leaves outside using , typedef because not allow forward declarations.

for value type fine:

class any_game_state : public boost::type_erasure::any< boost::mpl::vector<has_enter<void ()>,                    has_update<bool (std::chrono::milliseconds)>,                    has_exit<int ()>,                    has_get_resolution<std::pair<int, int> (),                                       const                                       boost::type_erasure::_self>,                    has_get_position<std::pair<int, int> (),                                     const                                     boost::type_erasure::_self>,                    has_get_scene_root<boost::any (), const                                       boost::type_erasure::_self>,                    boost::type_erasure::copy_constructible<>,                    boost::type_erasure::relaxed>> {     using base = boost::type_erasure::any<...identical_contents>;      using base::base; }; 

but when try same corresponding reference, not working:

class any_game_state_ref : public boost::type_erasure::any< boost::mpl::vector<has_enter<void ()>,                    has_update<bool (std::chrono::milliseconds)>,                    has_exit<int ()>,                    has_get_resolution<std::pair<int, int> (),                                       const                                       boost::type_erasure::_self>,                    has_get_position<std::pair<int, int> (),                                     const                                     boost::type_erasure::_self>,                    has_get_scene_root<boost::any (), const                                       boost::type_erasure::_self>,                    boost::type_erasure::copy_constructible<>,                    boost::type_erasure::relaxed>,                    boost::type_erasure::_self&> {     using base = boost::type_erasure::any<...identical_contents>;      using base::base; }; 

if use using "reference type" works fine, lose ability forward-declare reference type.

the error following:

in file included src/barvie/controller/game_action_state.cpp:3: in file included /usr/local/include/boost/type_erasure/any_cast.hpp:24: /usr/local/include/boost/type_erasure/any.hpp:1290:12: error: no type named 'type' in 'boost::disable_if, has_update >), boost::type_erasure::_self>, has_exit, has_get_resolution (), const boost::type_erasure::_self>, has_get_position (), const boost::type_erasure::_self>, has_get_scene_root, boost::type_erasure::copy_constructible, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::mpl::vector, has_update >), boost::type_erasure::_self>, has_exit, has_get_resolution (), const boost::type_erasure::_self>, has_get_position (), const boost::type_erasure::_self>, has_get_scene_root, boost::type_erasure::copy_constructible, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >, boost::is_const, mpl_::bool_, mpl_::bool_, mpl_::bool_ >, void>'

::type* = 0 ~~~^~~~ ../libbarvie/src/barvie/controller/any_game_state.hpp:95:17: note: in instantiation of member function 'boost::type_erasure::any, has_update >), boost::type_erasure::_self>, has_exit, has_get_resolution (), const boost::type_erasure::_self>, has_get_position (), const boost::type_erasure::_self>, has_get_scene_root, boost::type_erasure::copy_constructible, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::type_erasure::_self &>::any' requested here using base::base; ^ src/barvie/controller/game_action_state.cpp:291:18: note: while substituting deduced template arguments function template 'any_game_state_ref' [with concept2 = boost::mpl::vector, has_update >), boost::type_erasure::_self>, has_exit, has_get_resolution (), const boost::type_erasure::_self>, has_get_position (), const boost::type_erasure::_self>, has_get_scene_root, boost::type_erasure::copy_constructible, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, tag2 = boost::type_erasure::_self] (this, ^ in file included src/barvie/controller/game_action_state.cpp:3: in file included /usr/local/include/boost/type_erasure/any_cast.hpp:24: /usr/local/include/boost/type_erasure/any.hpp:1323:12: error: no type named 'type' in 'boost::disable_if, has_update >), boost::type_erasure::_self>, has_exit, has_get_resolution (), const boost::type_erasure::_self>, has_get_position (), const boost::type_erasure::_self>, has_get_scene_root, boost::type_erasure::copy_constructible, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::mpl::vector, has_update >), boost::type_erasure::_self>, has_exit, has_get_resolution (), const boost::type_erasure::_self>, has_get_position (), const boost::type_erasure::_self>, has_get_scene_root, boost::type_erasure::copy_constructible, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >, boost::is_const, mpl_::bool_, mpl_::bool_, mpl_::bool_ >, void>' ::type = 0 ~~~^~~~ ../libbarvie/src/barvie/controller/any_game_state.hpp:95:17: note: in instantiation of member function 'boost::type_erasure::any, has_update >), boost::type_erasure::_self>, has_exit, has_get_resolution (), const boost::type_erasure::_self>, has_get_position (), const boost::type_erasure::_self>, has_get_scene_root, boost::type_erasure::copy_constructible, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::type_erasure::_self &>::any' requested here using base::base; ^ src/barvie/controller/game_action_state.cpp:291:18: note: while substituting deduced template arguments function template 'any_game_state_ref' [with concept2 = boost::mpl::vector, has_update >), boost::type_erasure::_self>, has_exit, has_get_resolution (), const boost::type_erasure::_self>, has_get_position (), const boost::type_erasure::_self>, has_get_scene_root, boost::type_erasure::copy_constructible, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, tag2 = boost::type_erasure::_self &] (*this,

i found solution. solution give on inherited constructors reference type, instead of inherited constructor used equivalent by-hand inherited constructor. seems maybe templates mixed inherited constructors did not play well:

template <class...args> any_game_state_ref(args &&... args) : base(std::forward<args>(args)...) {} 

this did trick , can forward declare type erased references also.


Comments