[non-instrusive move] interest in new library?

Hi, Would there be interest for Boost in a small library providing a simple, non-instrusive emulation of move semantics for C++03 (though it could also be used in a C++11 environment)? It consists of a small number of 'move' function overloads, plus a trait class. It can be used facilitate move semantics/value-orientated programming in environments which lack/forbid C++11 or intrusive move libraries, and facilitate/force copy-elision and RVO optimisations in certain situations where they might otherwise not occur. Its mechanism is as follows: it detects at compile-time if the type of the argument(s) has a member swap function, and if so, it performs a swap, otherwise is calls the regular assignment operator. It can be used to provide an emulation of: move-assignment between lvalues moving an rvalue to an lvalue moving an lvalue to a temporary. It also supports moving between built-in arrays. Example use-cases are: //returning a value std::string foo(std::string s) { //append something to s //... //compiler can perform rvo, if just used 'return s;' compiler would not perform nrvo return move(s); } //passing a value std::string s("hello"); void bar(std::string s) {...} foo(s); //copy foo(move(s)); //move //moving a value into place void MyClass::MyClass(std::string s) { //move value into default constructed member move(s, s_); }
participants (1)
-
THOMAS JORDAN