Re: C++0x: move() & a hypotheticyl language feature
Vidar Hasfjord ha scritto:
On Nov 10, 6:31 pm, SG <s.gesem...@gmail.com> wrote:
[...]
Disclaimer: I'm going to describe a *hypothetical* language feature
that solves these kinds of "dangling reference" problems. This is not
a proposal for C++0x.
[...]
string&& operator+(string&& a : return, string const& b);
Interesting.
Here's an alternative syntax based on the new C++0x function
declaration syntax:
[] operator + (string&& a, string const& b) -> a;
Very nice. Please notice that the "unified" function declaration syntax
(the one using []) was not voted into the CD. However, the idea is still
good, if you replace [] with auto:
auto operator+(string&& a, string const& b) -> a;
Although probably less useful, we might also want to introduce a similar
syntax for member functions:
struct A
{
auto operator=(const A&) -> this // returns A&
};
the syntax should behave nicely with cv- and ref-qualifiers:
struct A
{
auto f() -> this // returns A&
auto g() & -> this // returns A&
auto g() && -> this // returns A&&
auto h() const -> this // returns const A&
};
HTH,
Ganesh
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]