@Abyx Virtual functions are pretty much the only place I can tell that would have a performance hit.
A virtual function call has double-indirection. Which isn't much. The problem is when you call a virtual method multiple times with different underlying objects.
the problem is that string literals are arrays, and arrays in C and C++ are really crippled. Then they decay to pointers, and pointers are just very, very primitive. :)
@Insilico I know how that feels. The other day, I had it right in one go (still had to go to ideone to OCD-check that, though): stackoverflow.com/questions/9874802/…
@Insilico Unless you care about nulltermination: array size of "Hello\0world" is 12, but strlen reports 5
bah, I hate programmers that learned everything from java. A colleague wrote a framework for a simple daemon in python, and even with all the paradigms you can use in python he managed to fuck it up in some over-the-top OO design with 20 classes already, half of them useless abstractions :(.
@Insilico in practice, by having the null terminator. But it could be implemented by copying the string buffer to some temporary location with room for the terminator
In C++11 basic_string::c_str is defined to be exactly the same as basic_string::data, which is in turn defined to be exactly the same as *(begin() + n) and *(&*begin() + n) (when 0 <= n < size()).
I cannot find anything that requires the string to always have a null character at its en...
@Insilico Not IMO. Most often I search for what I know exists. I use the votes rank, or otherwise I use 'newest' and use binary search to get to the period of time that I remember a question being posted
@Insilico Among others. I'd say, std::vector<char> is for contiguous storage of characters. But hey, that's just me
But there is no universal law stating that UTF16 should be used for text (in fact most OS-es favour UTF8, as do many other platforms like web/mail (HTTP/SMTP))
UTF-16 (16-bit Unicode Transformation Format) is a character encoding for Unicode capable of encoding 1,112,064 numbers (called code points) in the Unicode code space from 0 to 0x10FFFF. It produces a variable-length result of either one or two 16-bit code units per code point.
The older UCS-2 (2-byte Universal Character Set) is a similar character encoding that was superseded by UTF-16 in version 2.0 of the Unicode standard in July 1996. It produces a fixed-length format by simply using the code point as the 16-bit code unit and produces exactly the same result as UTF-16 for 96.9% of all...
Does wchar_t on *nix operating systems use UTF-8 or UTF-32?
@jalf By convention only, then. wchar_t is just a datatype. In what context do you think it (conventionally) implies a character encoding? You mean like in kernel calls?
but @Insilico was trying to figure out what char and wchar_ttypically meant on *nixes. I'd say utf8 and utf32 would be the answer then. I'm aware that neither of them actually enforce any particular encoding
@sehe sizeof(wchar_t), for example. Does that return 1, 2 or 4 bytes
Every time I've tested that on a *nix, it returned 4. Hence we can definitely rule out utf 8 and 16 as conventional encodings for wchar_t in those cases
but when you compile a program on Windows which uses a wchar_t, it will typically be compiled to use a 16-bit datatype. When you compile the same program on *nix, it will typically be compiled to use a 32-bit datatype
@sehe on *nix systems, char is utf8, and wchar_t is utf32, afaik
^^ that made me think you were talking about platforms, not compilers. Also kind of implied you were talking about character encoding conventions, not common datatype bit-lengths
@DeadMG Said by a puppy, a statement like this from you doesn't come with a lot of weight, though. ('In August was the Jackal bom; The Rains fell in September; “Now such a fearful flood as this,” Says he, “I can't remember!”' — Kipling)
When I try to write =<< and it doesn't work, and I then conclude that I must have just imagined that C++ had a left shift update operator, then I'm thinking early C syntax.