Boost logo

Boost :

Subject: [boost] Move semantics for std::string?
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2012-02-16 17:40:14


I'm using C++03 and would love some way to apply move semantics to a
std::string. Can boost facilitate this in some way without using smart
pointers? Consider an example like below (This is a contrived example, so
assume NRVO does not apply):

std::string GetInformation( int someNumber )
{
  // We use 'someNumber' to look up a string
  std::string myValue( "hello world" ); // Create the string here
  return myValue;
}

Above, the return value would result in a copy, I'd like to move it instead.

---------
Robert Dailey


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