Boost logo

Boost :

From: Rainer Deyke (root_at_[hidden])
Date: 2002-02-04 18:25:24


----- Original Message -----
From: "Howard Hinnant" <hinnant_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, February 04, 2002 2:26 PM
Subject: Re: [boost] auto_vector - vector with auto_ptr semantics

> The concept of move semantics is crucial for high performance,
exception
> safe code.

Agreed.

> What remains to be done is to settle on a uniform syntax for move
> semantics. John Maddock has suggested:
>
> T b = std::move(a);

What about return-by-move? I see two possibilities:

1. Use the same syntax:

  T f()
  {
    T a;
    return std::move(a);
  }

  T b(f());

This requires special compiler support to prevent 'a' from being
destroyed before 'b' is constructed.

2. Let the compiler handle it automatically:

  T f()
  {
    T a;
    return a;
  }

  T b(f());

Here the compiler realizes that 'a' will be destroyed immediately
after 'b' is constructed, so it uses the movement constructor instead
of the copy constructor if both are available.

--
Rainer Deyke | root_at_[hidden] | http://rainerdeyke.com

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