//Purpose: // Test any CTOR with static_binding arg. // #include #include #include #include #include #include #include #include #include #define USE_DEMANGLED #ifdef USE_DEMANGLED #include #define DEMANGLE_TYPE(TYPE) utility::demangled_type_name() #define DEMANGLE_EXPR(EXPR) utility::demangled_type_name(EXPR) #define DEMANGLE_INFO(INFO) utility::demangled_type_info(INFO) #else #include #define DEMANGLE_TYPE(TYPE) typeid(TYPE).name() #define DEMANGLE_EXPR(EXPR) DEMANGLE_TYPE(EXPR) #define DEMANGLE_INFO(INFO) INFO.name() #endif #include namespace mpl = boost::mpl; using namespace boost::type_erasure; unsigned value_instances=0; struct value_base { unsigned my_instance; value_base() : my_instance(value_instances++) {} value_base(value_base const&) : my_instance(value_instances++) {} value_base&operator=(value_base const&) { return *this; } virtual ~value_base() {} }; template struct ph_ctor_arg : value_base { typedef ph_ctor_arg type; virtual ~ph_ctor_arg(){} ph_ctor_arg() { std::cout<<__LINE__ <<":ph_ctor_arg<" <::CTOR.default" <<":my_instance=" <::CTOR.copy" <<":my_instance=" < struct ph_erasee : value_base { typedef ph_erasee type; virtual ~ph_erasee(){} unsigned my_instance; ph_erasee() { std::cout<<__LINE__ <<":ph_erasee<" <::CTOR.default" <<":my_instance=" <&) { std::cout<<__LINE__ <<":ph_erasee<" <::CTOR.(const ph_ctor_arg<"<&)" <<":my_instance=" < std::ostream& operator<< ( std::ostream&sout , ph_eraseeconst&x ) { sout <<"ph_erasee<" <.my_instance="< ph_erasee_type; typedef ph_ctor_arg<_a> ph_ctor_arg_type; typedef mpl::vector < destructible<_a> , typeid_<_a> , destructible<_b> , typeid_<_b> > ConceptA; typedef mpl::map < mpl::pair<_a, ph_erasee_type> , mpl::pair<_b, ph_ctor_arg_type> > bindings_map_t; static_binding bindings_map_v=make_binding(); typedef any < ConceptA , _a > AnyA; std::cout <<"std::is_copy_constructible=" <::value <<"\n"; ph_ctor_arg_type a_ctor_arg; std::cout<<"creating a_fst from a_ctor_arg\n"; AnyA a_fst ( a_ctor_arg , bindings_map_v ); ph_erasee_type const*fst_cast=any_cast(&a_fst); std::cout<<":*fst_cast=" <<*fst_cast <<":(void*)fst_cast=" <<(void const*)fst_cast <<"\n"; std::cout<<"typeid(*fst_cast).name()="<