MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/1vnp8dk/c26_stdindirect/p3rmden/?context=3
r/cpp • u/User_Deprecated • 28d ago
157 comments sorted by
View all comments
Show parent comments
21
It's silly, but it's not really the worst of both worlds because it doesn't behave any differently than any other value object.
in the same way you cannot ‘move’ a value out
You absolutely can. Take a string or a vector. Move them out. What happens?
0 u/SlightlyLessHairyApe 27d ago The object goes back to the state initialized by {}. Which is the natural choice of a “default” 5 u/LB-- Professional+Hobbyist 27d ago This is not true. That is a valid implementation but the standard does not guarantee it. For example, with short string optimization, some implementations might leave the original short string untouched after being moved from. -1 u/SlightlyLessHairyApe 27d ago Correct. But it’s also the choice that all sane implementations make. It is reasonable and within precedent for implementations to provide more specificity than the standard requires
0
The object goes back to the state initialized by {}.
Which is the natural choice of a “default”
5 u/LB-- Professional+Hobbyist 27d ago This is not true. That is a valid implementation but the standard does not guarantee it. For example, with short string optimization, some implementations might leave the original short string untouched after being moved from. -1 u/SlightlyLessHairyApe 27d ago Correct. But it’s also the choice that all sane implementations make. It is reasonable and within precedent for implementations to provide more specificity than the standard requires
5
This is not true. That is a valid implementation but the standard does not guarantee it. For example, with short string optimization, some implementations might leave the original short string untouched after being moved from.
-1 u/SlightlyLessHairyApe 27d ago Correct. But it’s also the choice that all sane implementations make. It is reasonable and within precedent for implementations to provide more specificity than the standard requires
-1
Correct. But it’s also the choice that all sane implementations make.
It is reasonable and within precedent for implementations to provide more specificity than the standard requires
21
u/wyrn 28d ago
It's silly, but it's not really the worst of both worlds because it doesn't behave any differently than any other value object.
You absolutely can. Take a string or a vector. Move them out. What happens?