$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] Formal Review Request: TypeErasure
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2012-06-18 13:43:38
AMDG
On 06/18/2012 09:45 AM, lcaminiti wrote:
> 
> 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?
> 
"abc" is an array.  I guess this means that
the constructor of any needs to handle
array-to-pointer decay.  Until I fix this,
you can use (const char*)"abc".
> #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 Christ,
Steven Watanabe