Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Kazutoshi Satoda <k_satoda@f2.dion.ne.jp> |
|---|---|
| Newsgroups | comp.std.c++ |
| Subject | Re: Defect Report: Wordings on basic_string::data() disallow small-string optimization |
| Date | 2011-08-28 08:42 -0700 |
| Organization | unknown |
| Message-ID | <4E58FF73.7070503@f2.dion.ne.jp> (permalink) |
The original subject was:
Defect Report: Wordings on basic_string::data() disallow small-string
optimization
The last "optimization" was wrapped and dropped from subject for some
reason (80 columns?).
Daniel Kr�gler wrote:
>
> On 2011-08-24 03:56, Kazutoshi Satoda wrote:
>>
>> void f(std::string& x, std::string&& str)
>> {
>> char const* const was_pointed = str.data();
>> x = std::move(str);
>> assert(x.data() == was_pointed);
>> }
(snip)
>
> You cannot make normative conclusions from this code, because it invokes
> undefined behaviour. This is so, because the expression
>
> x = std::move(str)
>
> calls a function that (potentially) invalidates the pointer returned
> fromstr.data(), ...
Then, replace the example with this one:
void f(std::string& x, std::string&& str)
{
char const* const was_pointed = str.data();
x = static_cast<std::string&&>(str);
assert(x.data() == was_pointed);
}
>> I think these wordings of effects on data() are unintentionally
>> over-constraining, and should be relaxed to keep the rationale for
>> C.2.11 "Allow small-string optimization" really valid.
>
> I have not yet seen an example which proves this. Your above given
> example is invalid.
I believe the above revised example is now good to show the problem.
--
k_satoda
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Back to comp.std.c++ | Previous | Next — Next in thread | Find similar
Re: Defect Report: Wordings on basic_string::data() disallow small-string optimization Kazutoshi Satoda <k_satoda@f2.dion.ne.jp> - 2011-08-28 08:42 -0700 Re: Defect Report: Wordings on basic_string::data() disallow small-string optimization Daniel Krügler<daniel.kruegler@googlemail.com> - 2011-08-28 11:06 -0700
csiph-web