Article View: pl.comp.lang.c
Article #309551[C++] Czy to jest lagalne?
From: Wojciech Muła
Date: Thu, 28 Dec 2017 11:11
Date: Thu, 28 Dec 2017 11:11
34 lines
1500 bytes
1500 bytes
Normalne kompilatory (GCC 7/clang 5) nie protestują.
Czy ten kod jest legalny? Chodzi o castowanie w capture().
--start--
#include <string>
class Item {
protected:
std::string a;
};
class Builder: public Item {
public:
void set() {
a = "foo";
}
Item&& capture() {
return std::move(*this);
}
};
int main() {
Builder b;
b.set();
Item a = b.capture();
}
--stop--
w.
Technical Details
Message-ID:
<f928db02-1940-40f1-95e9-241cc8966ed7@googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!fu-berlin.de!m31no2974331qtf.0!news-out.google.com!t48ni1024qtc.1!nntp.google.com!m31no2974328qtf.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Received: by 10.55.18.90 with SMTP id c87mr22371941qkh.43.1514459494121; Thu, 28 Dec 2017 03:11:34 -0800 (PST) X-Received: by 10.31.165.202 with SMTP id o193mr2873899vke.9.1514459493819; Thu, 28 Dec 2017 03:11:33 -0800 (PST) Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!fu-berlin.de!m31no2974331qtf.0!news-out.google.com!t48ni1024qtc.1!nntp.google.com!m31no2974328qtf.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: pl.comp.lang.c Date: Thu, 28 Dec 2017 03:11:33 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=131.228.32.167; posting-account=VFwkXwoAAADdT4-lLKRZrMYkTjizGoyn NNTP-Posting-Host: 131.228.32.167 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <f928db02-1940-40f1-95e9-241cc8966ed7@googlegroups.com> Subject: [C++] Czy to jest lagalne? From: Wojciech Muła <wojciech_mula@poczta.onet.pl> Injection-Date: Thu, 28 Dec 2017 11:11:34 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit