Boost logo

Boost Users :

Subject: Re: [Boost-users] [type_erasure] member function return any
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2017-03-06 15:45:44


AMDG

On 03/06/2017 04:59 AM, Mikhail Strelnikov via Boost-users wrote:
>
> I want to return type_erasure::any from a member function of a struct
> adapted by that same any. How can I do this?
>

For this to work you need to forward declare
the Concept:

struct my_concept;
using my_any = boost::type_erasure::any<my_concept>;
struct my_concept : boost::mpl::vector<
  copy_constructible<>,
  assignable<>,
  callable<my_any(my_any)>> {};

>
> #include <boost/type_erasure/any.hpp>
> #include <boost/type_erasure/callable.hpp>
>
> using my_any = boost::type_erasure::any<
> boost::mpl::vector<
> boost::type_erasure::copy_constructible<>,
> boost::type_erasure::assignable<>,
> boost::type_erasure::callable<? ? ?>
> >
>> ;
>
> struct s
> {
> my_any operator()(my_any v)
> {
> return v;
> }
> };
>
> int main()
> {
> my_any t = s{};
> t = t(t);
> }
>

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net