Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Our vision is to speed up time, eventually eliminating it." -- Alex Schure


devel / comp.lang.c++ / Still usable after having been moved?

SubjectAuthor
* Still usable after having been moved?Frederick Virchanza Gotham
+- Re: Still usable after having been moved?Alf P. Steinbach
`* Re: Still usable after having been moved?Malcolm McLean
 `- Re: Still usable after having been moved?Alf P. Steinbach

1
Still usable after having been moved?

<8b5f9308-2b49-4c7d-b3bb-d2b49b1d0d0cn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=803&group=comp.lang.c%2B%2B#803

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:622a:1046:b0:403:b167:3d33 with SMTP id f6-20020a05622a104600b00403b1673d33mr59838qte.6.1689198673339;
Wed, 12 Jul 2023 14:51:13 -0700 (PDT)
X-Received: by 2002:aca:bb46:0:b0:3a3:644a:b55 with SMTP id
l67-20020acabb46000000b003a3644a0b55mr5478917oif.4.1689198672895; Wed, 12 Jul
2023 14:51:12 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Wed, 12 Jul 2023 14:51:12 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=92.40.182.117; posting-account=w4UqJAoAAAAYC-PItfDbDoVGcg0yISyA
NNTP-Posting-Host: 92.40.182.117
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8b5f9308-2b49-4c7d-b3bb-d2b49b1d0d0cn@googlegroups.com>
Subject: Still usable after having been moved?
From: cauldwel...@gmail.com (Frederick Virchanza Gotham)
Injection-Date: Wed, 12 Jul 2023 21:51:13 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1589
 by: Frederick Virchanza - Wed, 12 Jul 2023 21:51 UTC

Link to GodBolt:

https://godbolt.org/z/KjEbGPWMT

And here it is copy-pasted:

#include <sstream>
#include <iostream>
#include <utility>

using std::stringstream, std::cout, std::endl;

void Func(std::stringstream &&arg)
{ static std::stringstream obj;

obj = std::move(arg);

cout << obj.str() << endl;
}

int main(void)
{ std::stringstream ss;

for ( unsigned i = 0u; i < 8u; ++i )
{
ss << i;

Func( std::move(ss) );
}
}

Should this code work properly on every implementation of the C++23 standard?

Re: Still usable after having been moved?

<u8oi6j$3ke5i$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=807&group=comp.lang.c%2B%2B#807

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: alf.p.st...@gmail.com (Alf P. Steinbach)
Newsgroups: comp.lang.c++
Subject: Re: Still usable after having been moved?
Date: Thu, 13 Jul 2023 12:04:01 +0200
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <u8oi6j$3ke5i$1@dont-email.me>
References: <8b5f9308-2b49-4c7d-b3bb-d2b49b1d0d0cn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 13 Jul 2023 10:04:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="33c9048e9edd6072864830b4814cd0b4";
logging-data="3815602"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Syrm3oLFDycFjRuM+zPpg"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:zFFT1cKMXS/1c7TrJgxz/VG5rDc=
Content-Language: en-US
In-Reply-To: <8b5f9308-2b49-4c7d-b3bb-d2b49b1d0d0cn@googlegroups.com>
 by: Alf P. Steinbach - Thu, 13 Jul 2023 10:04 UTC

On 2023-07-12 11:51 PM, Frederick Virchanza Gotham wrote:
> Link to GodBolt:
>
> https://godbolt.org/z/KjEbGPWMT
>
> And here it is copy-pasted:
>
> #include <sstream>
> #include <iostream>
> #include <utility>
>
> using std::stringstream, std::cout, std::endl;
>
> void Func(std::stringstream &&arg)
> {
> static std::stringstream obj;
>
> obj = std::move(arg);
>
> cout << obj.str() << endl;
> }
>
> int main(void)
> {
> std::stringstream ss;
>
> for ( unsigned i = 0u; i < 8u; ++i )
> {
> ss << i;
>
> Func( std::move(ss) );
> }
> }
>
>
> Should this code work properly on every implementation of the C++23 standard?

Yes, with a proper definition of "properly".

I doubt that you're guaranteed that `ss` retains its original state
after being moved from.

All you're guaranteed in general, is that the object is in a valid
state, i.e. that the class invariant is preserved.

---

Not what you're asking but regarding styles/conventions to me it seems
inconsistent to have a `using`-declaration of various things and then
refer to these things with namespace qualification.

Also inconsistent with C-ish `(void)` parameter list and C-ish type
builder operator attached to the declared name, in C++.

- Alf

Re: Still usable after having been moved?

<6bf963eb-a718-4d0f-bd41-1769a96f1038n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=808&group=comp.lang.c%2B%2B#808

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:620a:4092:b0:765:9bf7:29a5 with SMTP id f18-20020a05620a409200b007659bf729a5mr2944qko.8.1689243139076;
Thu, 13 Jul 2023 03:12:19 -0700 (PDT)
X-Received: by 2002:a05:6870:7711:b0:1b7:25d2:f5e5 with SMTP id
dw17-20020a056870771100b001b725d2f5e5mr1381013oab.8.1689243138707; Thu, 13
Jul 2023 03:12:18 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Thu, 13 Jul 2023 03:12:18 -0700 (PDT)
In-Reply-To: <8b5f9308-2b49-4c7d-b3bb-d2b49b1d0d0cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:4df:908f:29:1cd2;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:4df:908f:29:1cd2
References: <8b5f9308-2b49-4c7d-b3bb-d2b49b1d0d0cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6bf963eb-a718-4d0f-bd41-1769a96f1038n@googlegroups.com>
Subject: Re: Still usable after having been moved?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Thu, 13 Jul 2023 10:12:19 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2292
 by: Malcolm McLean - Thu, 13 Jul 2023 10:12 UTC

On Wednesday, 12 July 2023 at 22:51:22 UTC+1, Frederick Virchanza Gotham wrote:
> Link to GodBolt:
>
> https://godbolt.org/z/KjEbGPWMT
>
> And here it is copy-pasted:
>
> #include <sstream>
> #include <iostream>
> #include <utility>
>
> using std::stringstream, std::cout, std::endl;
>
> void Func(std::stringstream &&arg)
> {
> static std::stringstream obj;
>
> obj = std::move(arg);
>
> cout << obj.str() << endl;
> }
>
> int main(void)
> {
> std::stringstream ss;
>
> for ( unsigned i = 0u; i < 8u; ++i )
> {
> ss << i;
>
> Func( std::move(ss) );
> }
> }
>
>
> Should this code work properly on every implementation of the C++23 standard?
>
No. After an std::move() the only legal operations on an object are to assign it a new value,
or to destroy it. The object is in a well-formed but invalid state. Exactly what depends on
the implementation of the move constructor, and so if you implement the class yourself,
you can abuse the system and still write defined C++. But not if you use a class provided
by someone else.

Re: Still usable after having been moved?

<u8p2rv$3m2mg$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=813&group=comp.lang.c%2B%2B#813

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: alf.p.st...@gmail.com (Alf P. Steinbach)
Newsgroups: comp.lang.c++
Subject: Re: Still usable after having been moved?
Date: Thu, 13 Jul 2023 16:48:29 +0200
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <u8p2rv$3m2mg$1@dont-email.me>
References: <8b5f9308-2b49-4c7d-b3bb-d2b49b1d0d0cn@googlegroups.com>
<6bf963eb-a718-4d0f-bd41-1769a96f1038n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 13 Jul 2023 14:48:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="33c9048e9edd6072864830b4814cd0b4";
logging-data="3869392"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182JGMx3uQrvyQsDpEgBdAT"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:57tCOtNl2Ido8dZCXxjw4Q4in8M=
Content-Language: en-US
In-Reply-To: <6bf963eb-a718-4d0f-bd41-1769a96f1038n@googlegroups.com>
 by: Alf P. Steinbach - Thu, 13 Jul 2023 14:48 UTC

On 2023-07-13 12:12 PM, Malcolm McLean wrote:
> On Wednesday, 12 July 2023 at 22:51:22 UTC+1, Frederick Virchanza Gotham wrote:
>> Link to GodBolt:
>>
>> https://godbolt.org/z/KjEbGPWMT
>>
>> And here it is copy-pasted:
>>
>> #include <sstream>
>> #include <iostream>
>> #include <utility>
>>
>> using std::stringstream, std::cout, std::endl;
>>
>> void Func(std::stringstream &&arg)
>> {
>> static std::stringstream obj;
>>
>> obj = std::move(arg);
>>
>> cout << obj.str() << endl;
>> }
>>
>> int main(void)
>> {
>> std::stringstream ss;
>>
>> for ( unsigned i = 0u; i < 8u; ++i )
>> {
>> ss << i;
>>
>> Func( std::move(ss) );
>> }
>> }
>>
>>
>> Should this code work properly on every implementation of the C++23 standard?
>>
> No. After an std::move() the only legal operations on an object are to assign it a new value,
> or to destroy it. The object is in a well-formed but invalid state. Exactly what depends on
> the implementation of the move constructor, and so if you implement the class yourself,
> you can abuse the system and still write defined C++. But not if you use a class provided
> by someone else.

No. Current standard draft, <url:
https://eel.is/c++draft/lib.types.movedfrom>

<<
16.4.6.15 Moved-from state of library types[lib.types.movedfrom]
1 Objects of types defined in the C++ standard library may be moved from
([class.copy.ctor]). Move operations may be explicitly specified or
implicitly generated. Unless otherwise specified, such moved-from
objects shall be placed in a valid but unspecified state.
2 An object of a type defined in the C++ standard library may be
move-assigned ([class.copy.assign]) to itself. Unless otherwise
specified, such an assignment places the object in a valid but
unspecified state.
>>

- Alf


devel / comp.lang.c++ / Still usable after having been moved?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor