|
Boost : |
Subject: Re: [boost] Formal Review Request: TypeErasure
From: lcaminiti (lorcaminiti_at_[hidden])
Date: 2012-06-18 12:45:31
lcaminiti wrote
>
> I will use the lib in some use cases that I ran into the past and let you
> know if I find a nice example not too complex (I don't remember what the
> use cases were but they were about type erasure).
>
Why this does not compile?
#include <boost/type_erasure/any.hpp>
#include <boost/type_erasure/builtin.hpp>
#include <boost/type_erasure/operators.hpp>
#include <boost/mpl/vector.hpp>
#include <iostream>
struct display
{
public: template< typename T >
explicit display ( T const& obj ) : obj_(obj) {}
public: void print ( void ) { std::cout << obj_ << std::endl; }
private: boost::type_erasure::any<
boost::mpl::vector<
boost::type_erasure::copy_constructible<>
, boost::type_erasure::typeid_<>
, boost::type_erasure::ostreamable<>
>
> obj_;
};
int main ( void )
{
display i(123), s("abc");
i.print();
s.print();
return 0;
}
Using GCC 4.5.3 on Cygwin with Boost 1.50.0 Beta 1, I get:
In file included from ../boost/type_erasure/detail/access.hpp:14:0,
from ../boost/type_erasure/any.hpp:34,
from 01.cpp:2:
../boost/type_erasure/detail/storage.hpp: In constructor
ââ¬Ëboost::type_erasure::detail::storage::storage(const T&) [with T = char
[4]]ââ¬â¢:
../boost/type_erasure/any.hpp:167:22: instantiated from
ââ¬Ëboost::type_erasure::any<Concept, T>::any(const U&) [with U = char [4],
Concept = boost::mpl::vector<boost::type_erasure::copy_constructible<>,
boost::type_erasure::typeid_<>, boost::type_erasure::ostreamable<> >, T =
boost::type_erasure::_self]ââ¬â¢
01.cpp:11:49: instantiated from ââ¬Ëdisplay::display(const T&) [with T =
char [4]]ââ¬â¢
01.cpp:26:28: instantiated from here
../boost/type_erasure/detail/storage.hpp:24:44: error: ISO C++ forbids
initialization in array new
In file included from
../../../1_50_0_beta1.cygwin/boost/preprocessor/iteration/detail/iter/forward1.hpp:52:0,
from
../boost/type_erasure/detail/rebind_placeholders.hpp:127,
from ../boost/type_erasure/detail/normalize.hpp:31,
from ../boost/type_erasure/any.hpp:36,
from 01.cpp:2:
../boost/type_erasure/detail/rebind_placeholders.hpp: At global scope:
../boost/type_erasure/detail/rebind_placeholders.hpp: In instantiation of
ââ¬Ëboost::type_erasure::detail::rebind_placeholders_in_argument<boost::type_erasure::_self(const
boost::type_erasure::_self&),
boost::mpl::map<boost::mpl::pair<boost::type_erasure::_self, char
[4]>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
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/detail/rebind_placeholders.hpp:149:63: instantiated
from
ââ¬Ëboost::type_erasure::detail::rebind_placeholders<boost::type_erasure::constructible<boost::type_erasure::_self(const
boost::type_erasure::_self&)>,
boost::mpl::map<boost::mpl::pair<boost::type_erasure::_self, char [4]>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
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/detail/adapt_to_vtable.hpp:53:7: instantiated from
ââ¬Ëboost::type_erasure::detail::rebind_placeholders<boost::type_erasure::detail::vtable_adapter<boost::type_erasure::constructible<boost::type_erasure::_self(const
boost::type_erasure::_self&)>,
boost::type_erasure::detail::storage(const
boost::type_erasure::detail::storage&)>,
boost::mpl::map<boost::mpl::pair<boost::type_erasure::_self, char [4]>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >ââ¬â¢
../../../1_50_0_beta1.cygwin/boost/mpl/aux_/has_type.hpp:20:1:
instantiated from ââ¬Ëconst bool
boost::mpl::aux::has_type<boost::type_erasure::detail::rebind_placeholders<boost::type_erasure::detail::vtable_adapter<boost::type_erasure::constructible<boost::type_erasure::_self(const
boost::type_erasure::_self&)>,
boost::type_erasure::detail::storage(const
boost::type_erasure::detail::storage&)>,
boost::mpl::map<boost::mpl::pair<boost::type_erasure::_self, char [4]>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >, mpl_::bool_<true>
>::valueââ¬â¢
../../../1_50_0_beta1.cygwin/boost/mpl/aux_/has_type.hpp:20:1:
instantiated from
ââ¬Ëboost::mpl::aux::has_type<boost::type_erasure::detail::rebind_placeholders<boost::type_erasure::detail::vtable_adapter<boost::type_erasure::constructible<boost::type_erasure::_self(const
boost::type_erasure::_self&)>,
boost::type_erasure::detail::storage(const
boost::type_erasure::detail::storage&)>,
boost::mpl::map<boost::mpl::pair<boost::type_erasure::_self, char [4]>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >, mpl_::bool_<true> >ââ¬â¢
../../../1_50_0_beta1.cygwin/boost/mpl/aux_/preprocessed/gcc/quote.hpp:56:5:
instantiated from
ââ¬Ëboost::mpl::quote2<boost::type_erasure::detail::rebind_placeholders,
mpl_::void_>::apply<boost::type_erasure::detail::vtable_adapter<boost::type_erasure::constructible<boost::type_erasure::_self(const
boost::type_erasure::_self&)>,
boost::type_erasure::detail::storage(const
boost::type_erasure::detail::storage&)>,
boost::mpl::map<boost::mpl::pair<boost::type_erasure::_self, char [4]>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >ââ¬â¢
../../../1_50_0_beta1.cygwin/boost/mpl/aux_/preprocessed/gcc/apply_wrap.hpp:49:1:
[ skipping 14 instantiation contexts ]
../../../1_50_0_beta1.cygwin/boost/mpl/transform.hpp:138:1: instantiated
from
ââ¬Ëboost::mpl::transform<boost::mpl::v_item<boost::type_erasure::detail::vtable_adapter<boost::type_erasure::ostreamable<>,
void(std::basic_ostream<char>&, const
boost::type_erasure::detail::storage&)>,
boost::mpl::v_item<boost::type_erasure::typeid_<>,
boost::mpl::v_item<boost::type_erasure::destructible<boost::type_erasure::_self>,
boost::mpl::v_item<boost::type_erasure::detail::vtable_adapter<boost::type_erasure::constructible<boost::type_erasure::_self(const
boost::type_erasure::_self&)>,
boost::type_erasure::detail::storage(const
boost::type_erasure::detail::storage&)>, boost::mpl::vector0<mpl_::na>, 0>,
0>, 0>, 0>,
boost::type_erasure::detail::rebind_placeholders<mpl_::arg<1>,
boost::mpl::map<boost::mpl::pair<boost::type_erasure::_self, char [4]>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, 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/binding.hpp:163:13: instantiated from
ââ¬Ëboost::type_erasure::binding<Concept>::impl_type::impl_type(const
boost::type_erasure::static_binding<Map>&) [with Map =
boost::mpl::map<boost::mpl::pair<boost::type_erasure::_self, char [4]>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, Concept =
boost::mpl::vector<boost::type_erasure::copy_constructible<>,
boost::type_erasure::typeid_<>, boost::type_erasure::ostreamable<> >]ââ¬â¢
../boost/type_erasure/binding.hpp:94:35: instantiated from
ââ¬Ëboost::type_erasure::binding<Concept>::binding(const
boost::type_erasure::static_binding<Map>&) [with Map =
boost::mpl::map<boost::mpl::pair<boost::type_erasure::_self, char [4]>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, Concept =
boost::mpl::vector<boost::type_erasure::copy_constructible<>,
boost::type_erasure::typeid_<>, boost::type_erasure::ostreamable<> >]ââ¬â¢
../boost/type_erasure/any.hpp:167:22: instantiated from
ââ¬Ëboost::type_erasure::any<Concept, T>::any(const U&) [with U = char [4],
Concept = boost::mpl::vector<boost::type_erasure::copy_constructible<>,
boost::type_erasure::typeid_<>, boost::type_erasure::ostreamable<> >, T =
boost::type_erasure::_self]ââ¬â¢
01.cpp:11:49: instantiated from ââ¬Ëdisplay::display(const T&) [with T =
char [4]]ââ¬â¢
01.cpp:26:28: instantiated from here
../boost/type_erasure/detail/rebind_placeholders.hpp:161:64: error: function
returning an array
In file included from
../../../1_50_0_beta1.cygwin/boost/preprocessor/iteration/detail/iter/forward1.hpp:67:0,
from ../boost/type_erasure/detail/vtable.hpp:191,
from ../boost/type_erasure/binding.hpp:28,
from ../boost/type_erasure/any.hpp:39,
from 01.cpp:2:
../boost/type_erasure/detail/vtable.hpp: In instantiation of ââ¬Ëconst
boost::type_erasure::detail::vtable_storage4<boost::type_erasure::detail::vtable_adapter<boost::type_erasure::constructible<boost::type_erasure::_self(const
boost::type_erasure::_self&)>,
boost::type_erasure::detail::storage(const
boost::type_erasure::detail::storage&)>,
boost::type_erasure::destructible<boost::type_erasure::_self>,
boost::type_erasure::typeid_<>,
boost::type_erasure::detail::vtable_adapter<boost::type_erasure::ostreamable<>,
void(std::basic_ostream<char>&, const
boost::type_erasure::detail::storage&)> >
boost::type_erasure::detail::vtable_init4<boost::type_erasure::detail::vtable_storage4<boost::type_erasure::detail::vtable_adapter<boost::type_erasure::constructible<boost::type_erasure::_self(const
boost::type_erasure::_self&)>,
boost::type_erasure::detail::storage(const
boost::type_erasure::detail::storage&)>,
boost::type_erasure::destructible<boost::type_erasure::_self>,
boost::type_erasure::typeid_<>,
boost::type_erasure::detail::vtable_adapter<boost::type_erasure::ostreamable<>,
void(std::basic_ostream<char>&, const
boost::type_erasure::detail::storage&)> >,
boost::type_erasure::detail::rebind_placeholders<boost::type_erasure::detail::vtable_adapter<boost::type_erasure::constructible<boost::type_erasure::_self(const
boost::type_erasure::_self&)>,
boost::type_erasure::detail::storage(const
boost::type_erasure::detail::storage&)>,
boost::mpl::map<boost::mpl::pair<boost::type_erasure::_self, char [4]>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
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::destructible<char [4]>,
boost::type_erasure::typeid_<char [4]>,
boost::type_erasure::detail::vtable_adapter<boost::type_erasure::ostreamable<std::basic_ostream<char>,
char [4]>, void(std::basic_ostream<char>&, const
boost::type_erasure::detail::storage&)> >::valueââ¬â¢:
../boost/type_erasure/binding.hpp:163:13: instantiated from
ââ¬Ëboost::type_erasure::binding<Concept>::impl_type::impl_type(const
boost::type_erasure::static_binding<Map>&) [with Map =
boost::mpl::map<boost::mpl::pair<boost::type_erasure::_self, char [4]>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, Concept =
boost::mpl::vector<boost::type_erasure::copy_constructible<>,
boost::type_erasure::typeid_<>, boost::type_erasure::ostreamable<> >]ââ¬â¢
../boost/type_erasure/binding.hpp:94:35: instantiated from
ââ¬Ëboost::type_erasure::binding<Concept>::binding(const
boost::type_erasure::static_binding<Map>&) [with Map =
boost::mpl::map<boost::mpl::pair<boost::type_erasure::_self, char [4]>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, Concept =
boost::mpl::vector<boost::type_erasure::copy_constructible<>,
boost::type_erasure::typeid_<>, boost::type_erasure::ostreamable<> >]ââ¬â¢
../boost/type_erasure/any.hpp:167:22: instantiated from
ââ¬Ëboost::type_erasure::any<Concept, T>::any(const U&) [with U = char [4],
Concept = boost::mpl::vector<boost::type_erasure::copy_constructible<>,
boost::type_erasure::typeid_<>, boost::type_erasure::ostreamable<> >, T =
boost::type_erasure::_self]ââ¬â¢
01.cpp:11:49: instantiated from ââ¬Ëdisplay::display(const T&) [with T =
char [4]]ââ¬â¢
01.cpp:26:28: instantiated from here
../boost/type_erasure/detail/vtable.hpp:266:49: error: ââ¬Ëvalueââ¬â¢ is not a
member of
ââ¬Ëboost::type_erasure::detail::rebind_placeholders<boost::type_erasure::detail::vtable_adapter<boost::type_erasure::constructible<boost::type_erasure::_self(const
boost::type_erasure::_self&)>,
boost::type_erasure::detail::storage(const
boost::type_erasure::detail::storage&)>,
boost::mpl::map<boost::mpl::pair<boost::type_erasure::_self, char [4]>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >ââ¬â¢
Thanks,
--Lorenzo
-- View this message in context: http://boost.2283326.n4.nabble.com/Formal-Review-Request-TypeErasure-tp4630373p4631465.html Sent from the Boost - Dev mailing list archive at Nabble.com.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk