Boost logo

Boost Users :

Subject: Re: [Boost-users] [TypeErasure] efficiency problem
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2017-03-23 15:48:03


AMDG

On 03/22/2017 11:55 PM, Mikhail Strelnikov via Boost-users wrote:
>
> In following code TypeErasure creates two copies of s, while Boost.Any
> creates no copies at all.
>
> any x{ s{} };
> any y{ std::move(x) };

  Boost.TypeErasure tries to be as faithful as possible
to normal overload resolution rules. As a result,
the move constructor should resolve as follows:
If constructible<P(P&&)> is present
  Allocate a new object and call the captured move
  constructor to initialize it.
Else if constructible<P(const P&)> is present
  Allocate a new object and initialize it with the
  copy constructor.
Else
  Error

  If relaxed is present, then it would be possible
to move the pointer, leaving the source any empty,
but this isn't currently implemented.

> any z;
> z = std::move(y);
>
> There is move constructor for type_erasure::any, but it does allocate
> memory and calls copy constructor for s. Why?
>
> And why there is no move assignment operator in type_erasure::any?
>

There will be once I get around to merging Deniz' PR.

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