Toot
Written by Dani (:cxx: modules addict) on 2025-01-19 at 11:29
@sickeroni @dermojo Shouldn't be the distinction more along the line of object independence, and the rest follows from there?
You have two cases:
- you got an independent object (i.e. by-value function parameter), or a reference to a materialized pr-value / abandoned x-value. Then you can manipulate such an object to your hearts content whereever it currently lives. It's yours.
- you're dealing with an object outside your control. In other words: you got a l-value reference. Now you have two sub-cases:
- the function parameter refers to a constant object that you may only observe. If this doesn't suffice, this means you have to create a copy before or during manipulation.
- the parameter refers to a non-constant object. Now you're stumped:
- this could be an old-fashioned in-out or out parameter with unclear semantics that you should avoid anyway
- this could be meant to be manipulated in place
- this could be meant to be treated like a const reference and the programmer was sloppy and didn't think about concurrency
- this could mean something else
I hope this leads you to an example that demonstrates your teaching intent.
[#]cpp
=> More informations about this toot | View the thread | More toots from DanielaKEngert@hachyderm.io
Mentions
=> View sickeroni@mastodon.social profile | View dermojo@hachyderm.io profile
Tags
=> View cpp tag
Proxy Information
- Original URL
- gemini://mastogem.picasoft.net/toot/113854784714824649
- Status Code
- Success (20)
- Meta
text/gemini
- Capsule Response Time
- 299.935438 milliseconds
- Gemini-to-HTML Time
- 0.952763 milliseconds
This content has been proxied by September (3851b).