Boost logo

Boost :

Subject: Re: [boost] [TypeErasure] Forward constructors and binded types
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2012-07-18 17:01:56


AMDG

On 07/18/2012 01:32 PM, Fabio Fracassi wrote:
>
> Just spelling out some thoughts I had while reading the docu:
>
> Even though, it would help to have this information in the docu. The way
> it is written now feels a bit like playing Jeopardy, you present
> solutions and the reader tries to figure out the problem.
>
> additionally I do not quite gasp on what I could use this feature for.
> the above is much more complex as using
> any<...> v = std::vector<double>(10, 2.5);
> what am I buying with it?
>

The point is to allow constructors
to be captured just like any other
function. When the constructor is
called, you don't have to know the
contained types.

Also, this feature has one very obvious
use: the copy constructor. If we
need the ability to copy an any<Concept, _a>,
then Concept needs to include
constructible<_a(const _a&)>.

> And couldn't another syntax like
> any<...> v(binding_of(vec), (int)10, (double)2.5);
> be made to work, and be much more comfortable?
>

- binding_of takes an any as an argument.
  vec is a std::vector.
- This syntax does, in fact, work if the Concept
  includes construcible<_a(int, double)> and
  if we replace vec with an any.

In Christ,
Steven Watanabe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk