R. Martinho Fernandes

Nov 2, 2021 19:53
@Rhubarb: +1, very interesting answer, shows arguments for both sides. Great. About your last comment: note that declaring throws on each method up the call stack may not always be possible, especially if you are implementing an interface along the way.
 
Apr 20, 2018 16:03
Yes, things look hopeful now. Since last month there is an actual official study group with people who know about this stuff working on this.
Apr 20, 2018 15:58
(In practice some implementations let you pick with flags)
Apr 20, 2018 15:58
The implementation can pick any encoding.
Apr 20, 2018 15:58
Ah, that's the implementation-defined bit.
Apr 20, 2018 15:55
@Sergey.quixoticaxis.Ivanov what kind of mapping you mean?
Apr 20, 2018 15:55
We'll want to reword large sections of the standard because of this stuff.
Apr 20, 2018 15:54
No worries.
Apr 20, 2018 15:53
Yes.
Apr 20, 2018 15:53
So the translation will map some bytes to A or to 🍌, but it won't map 🍌 to anything, because the input is bytes, not "characters".
Apr 20, 2018 15:53
When the standard says "Physical source file characters are mapped (...)" it means... bytes.
Apr 20, 2018 15:53
The problem here is the word "character" (sigh, something else we need to comb the standard for to fix). The C-word, when discussing Unicode. Abused to mean anything and everything :(.
Apr 20, 2018 15:52
(Well, you can decode to a u16string, but not to a UTF-16 u16string :D)
Apr 20, 2018 15:52
@bit2shift There's some confusion. Note I said UTF-8 isn't supported as the "deserialized" form (implying that UTF-16 is the "serialized" end of the conversion, meaning it comes as bytes, not as 16-bit units). I edited the text for clarity now to say "from a UTF-16 byte stream". If you have a stream of bytes, you can't decode those to UTF-8 (you can't even decode those to a u16string because codecvt_utf16<char16_t> converts to UCS-2, against all odds)
Apr 20, 2018 15:52
If you are using a source encoding that can't encode bananas, then you "can't type it", so there's no behaviour to discuss. If you mean that the current normative references refer to ISO/IEC 10646-1:1993, which is pre-Unicode 2.0, and thus only covers code points up to U+FFFF, then yes, technically the standard doesn't prescribe the behaviour. However, it's pretty clear that ISO/IEC 10646-1:1993 is intended to be included with all amendments, since the standard refers to things like "UTF-8", "UTF-16", "surrogate pairs", and the 0000-10FFFF range. This is a defect we (SG16) are working on atm.
Apr 20, 2018 15:52
@Sergey.quixoticaxis.Ivanov what do you mean by "C++ ISO(2.3)"? There's no leeway for implementation defined behaviour here. See eel.is/c++draft/lex.string#9. If you can type it, your implementation must make it { 0xF0, 0x9F, 0x8D, 0x8C, 0 }. UTF-8 doesn't care what the character looks like: it encodes any thing from U+0000 to U+10FFFF (excluding U+D800 to U+DFFF), regardless of what meaning it has. So, unless you're using a source encoding that can't encode U+1F34C BANANA, there's no implementation-defined behaviour.
Apr 20, 2018 15:52
@Alexandros thanks for noticing! I fixed it. (You can do 1-char edits after a certain rep level, if I recall correctly)
Apr 20, 2018 15:52
@DanNissenbaum I edited the answer, tiptoeing around the terminology.
Apr 20, 2018 15:52
Thanks for the feedback! I'll update the answer when I'm not browsing from a phone. But you misunderstood (could be my fault). The bytes end is always with char and is the external end. The "wide" end can be of any type and is the internal end. "Narrow/wide" is really not the same thing. The standard just uses really confusing terminology for orthogonal concepts. I'll be extra careful updating the answer to make sure I steer clear of that confusion.
Apr 20, 2018 15:52
@Dan does that make it clearer? If so, I'll put it in the answer.
Apr 20, 2018 15:52
... no matter how you want to store it (but wchar_t would be stupid). Unless, of course, it's an identity conversion. This whole thing just feels yucky. Whoever designed this had no idea what they were doing, and the committee approved it :(
Apr 20, 2018 15:52
No. wstring_convert always converts from what the standard calls a 'byte' string to what the standard calls a 'wide' string. This choice of words is quite confusing (I should reword the answer, I guess). A better choice would be 'serialized' and 'deserialized'. 'Serialized' is always as bytes meant for use external to your program (a file, the network, whatever), and 'deserialized' is always as whatever your program wants to use internally. In the list of conversions I gave the left is serialized and the right is deserialized. There is no provided way to deserialize anything into UTF-8...
Apr 20, 2018 15:52
@graham.reeds haha, thanks, but I was aware of that. Check the "Acknowledgments" section ;)
Apr 20, 2018 15:52
@Uflex maybe. I don't know if following advice you don't understand is a good idea.
 

Lounge<C++>

Today we're daydreaming about C++26 reflection
Sep 4, 2017 13:56
If anyone could help me find the standard sections to refer to, that'd be sweet.
Sep 4, 2017 13:55
1
A: Is there any environment where "int" would cause struct padding?

R. Martinho Fernandes Is there any reasonable (not necessarily common or current) environment where this small program would print bigger? Not that I know of. I know that's not completely reassuring, but I have reason to believe there is no such environment due to the requirements imposed by the C++ standard. In...

Sep 4, 2017 13:18
I suppose an architecture that has structs and arrays as primitives could, in theory, force this requirement. But again, if it can make it work without padding for arrays, it stands to reason it could also be made to work with structs.
Sep 4, 2017 13:15
(This is to say: I don't think it could happen in a "real" architecture, but Hell++ is allowed to have this happen in the struct but not in arrays because structs and arrays are not layout-compatible)
Sep 4, 2017 13:14
Anyway, consider that whatever reason would make this happen in a struct would likely apply to arrays as well, and in arrays there can be no padding.
Sep 4, 2017 13:13
Sounds better.
Sep 4, 2017 13:12
Phrasing it in terms of alignment is a tautology if you ignore blatantly non-compliant compilers.
Sep 4, 2017 13:12
Then mention padding directly.
Sep 4, 2017 13:11
I don't see how an architecture would affect the layout of structs.
Sep 4, 2017 13:11
Padding in the middle?
Sep 4, 2017 13:11
What do you mean, really?
Sep 4, 2017 13:10
@BartekBanachewicz Still wrong.
Sep 4, 2017 13:10
In either case, the padding would have to be a whole multiple of the size of int, and it would be completely unnecessary.
Sep 4, 2017 13:10
That's arguably a compiler bug.
Sep 4, 2017 13:09
Actually, also padding in the middle.
Sep 4, 2017 13:08
The only way for that to print "bigger" is with trailing padding (which is not needed for alignment purposes, from which follows that only Hell++ would do this).
Sep 4, 2017 13:07
"Unaligned" is wrong too. They're always aligned.
Sep 4, 2017 13:00
@BartekBanachewicz If that's what you mean, then by definition, no.
Sep 4, 2017 11:42
Yes, but there are plenty of other bankers. You said they only own some billions of the 20T debt. That's less than 5%. Yet you felt the need to single them out from "the world".
Sep 4, 2017 11:39
@Joe Dunno, you seemed to want to draw a distinction between "the world" and "the rothchild family" for some reason.
Sep 4, 2017 11:35
Added parens to distinguish from other kinds of NWO.
Sep 4, 2017 11:35
That's usually a (((NWO))) red flag.
Sep 4, 2017 11:34
@Fanael He brought up the debt "to the world and the rothchild family".
Sep 4, 2017 11:31
Anyway, it seems I won't be getting the antisemitic bits out of him, so no kicking :(
Sep 4, 2017 11:30
He said above since December 2016.
Sep 4, 2017 11:29
@Rerito Er, no, it is as he says. The conclusions may be complete bollocks, but at least this is factually correct.