« first day (528 days earlier)      last day (4435 days later) » 

8:00 AM
And I'm still at home
@Mysticial That's i7 not?
 
cya
@sehe Yeah, it's a Sandy Bridge i7. I put 1.4 volts into for 6 months and then it started BSODing under moderate loads... lol
 
Lol, just found this.
It's pretty huge.
 
@StackedCrooked: Is it any good?
 
Don't know yet.
 
Personally I hate videos when learning this kind of stuff
It's way faster for me to read it
 
8:03 AM
Implementing object inheritance in C is an art... lol
 
But I can't knock on them since I'm sure they are of great help to lots of other people
 
really forces you to think about thinks...
 
@Mysticial More like a hack. :-)
Quite impressive to have a 70+ series on C++
 
Got a large C program that needs a very tiny amount of inheritance.
 
Done via composition, I presume?
 
8:07 AM
Function pointer tables or something.
I haven't got much experience in that regard.
 
@StackedCrooked Yeah, function pointers and vtables.
It's actually not that bad once you know exactly how it's supposed to work.
 
Yeah, but there is a reason why C++ does it for you automatically. :-)
 
Yeah, if more than 2% of the program needed C++, I'd switch the whole thing to C++.
2
I had to write a "simple" compiler for one of my classes last year. That kinda forced me to learn how inheritance works underneath.
And how it can potentially wreak havoc on performance if abused properly.
 
8:23 AM
@Mysticial and how it can, besides virtual functions?
 
@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.
 
ohai
is what I'm doing here UB in C?
 
@TonyTheLion you just leak memory, and free string literal
 
that's a bad idea
 
@Abyx what does it segfault though?
 
8:27 AM
@TonyTheLion you overwrite the pointer, not the content, you need some function from string.h
 
@TonyTheLion you should use strcpy, not =
 
like strcpy right?
 
@TonyTheLion because you're accessing some 'random' memory when you're printing value and freeing that same random memory afterwards
 
@TonyTheLion try free("true"), it's exactly what you do
 
it's funny that you can't write a string of chars by using =
 
8:30 AM
@TonyTheLion it's no string
 
@TonyTheLion it's not "string", it's pointer to array
 
isn't char * mystr = malloc(5 * sizeof(char)); allocating memory for a string of bytes
 
No it's allocating memory, that you can use however you want
 
but you can't write to the memory using *mystr = "bla";
which is odd, imho
 
char * mystr; does not magically become something like C++'s std::string, you have to take care what you do with your pointer and the memory
 
8:32 AM
@TonyTheLion It's the same deal as you can't assign to char[]
 
@TonyTheLion You can't assign arrays, so "bla" is converted to a pointer. What usually happens when you assign a pointer?
 
but you have memory, and you can't directly write to it, you have to use strcpy which seems odd to me
@jalf it points to some memory location, now the location where "blah" resides
 
@TonyTheLion C strings are odd
 
@TonyTheLion you can directly write to it, you can perfectly do *mystr = 'b'; But string literals are something different
 
@TonyTheLion yup. So the same thing happens with C strings.
 
8:33 AM
@KillianDS hah, I think that's my confusion
a string literal such as "blah" is not the same as a single character, such as 'c'
 
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. :)
 
@TonyTheLion well.. in C++ you can assign arrays - ideone.com/h70wQ
 
@Abyx strange
@jalf right, decay to pointers, I guess this makes the whole thing seem odd
 
There's a reason why std::string was invented. :-)
 
@KillianDS so you could do mystr[2] = 'a'; too?
 
8:36 AM
@Abyx Wow, I never saw that.
 
char* is an unbeliveably stupid datatype for storing strings in C++
 
@TonyTheLion yes
 
@Insilico in C++, but not in C
 
@TonyTheLion TBH, just write it std::string as a C pseudo-class.
you'll be better off than trying to use null-terminated const char*
 
@TonyTheLion there is a reason why string.h was invented there :p
 
8:37 AM
hmmm
 
@Abyx that is making my head hurt
 
hm... actually it doesn't work =(
ideone.com/X5A0h - error: invalid array assignment
 
yeah
auto would have caused pointer decay, which explains why I was confused :P
 
I was so happy when my university finally has Visual Studio 2010 installed on their lab machines
Now I don't have to take my laptop around just to try out some C++11 features
 
I have never seen this char(&value)[5] = (char(&)[5])mem;
what does this do?
 
8:43 AM
I think you're assigning a reference to mem into value, where mem is an array of 5 chars.
 
@Insilico I like how we can't even figure out what the code is doing
 
@TonyTheLion (char(&)[5]) - it's C-style cast to reference to array
 
Fuck, the English language has horrible syntax
 
haha
 
> a reference to mem to value
That's confusing as hell
Saying "into" value is better but still a bit weird
@jalf: Yeah it's one of those things I almost never write
The only time I use something like char(&)[5] is when I'm writing this
 
8:46 AM
I wish it'd be char[5]& value = (char[5]&)mem;
 
template<size_t N>
void foo(const char (&arr)[N]) { /*...*/ }
And every single time I need to write that I have to look it up
 
@Insilico I write such thing nearly every time when I want to pass string literal
probably it's because of C++03
 
@Abyx: It works with string literals too?
So foo("Hello World!") works?
 
@Insilico sure
string literals are references to arrays
 
So this entire time I could get the length of string literals in O(1) time?
@Abyx: D'oh! >_< My brain has not made that kind of connection until now
 
8:51 AM
@Insilico yep, and without things like foo("123", strlen("123"))
 
So I knew how to do something without knowing that I could do that something.
Awesome.
I will now require everyone to write const char strlit[] = "Hello World" instead of const char* strlit = "Hello World".
Since the latter doesn't work with the template deduction magic
 
@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
 
@sehe: I'm going to assume the non-evil-stupid programmer case holds. :-)
 
@Insilico Just require auto strlit = "Hello World"; then
 
Also, if I'm copying the string I would probably check for 0 anyway
 
9:00 AM
@Insilico What? NUL-chars aren't evil. It just depends on the use case
 
@sehe: Unfortunately not everyone is up to speed with C++11 yet
 
@sehe Actually, doesn't that invoke decay?
I thought you would have to do auto&& strlit = "Hello World";
 
@DeadMG my guess is it doesn't. That is because the rhs should be a prvalue in my opinion. But I may be wrong
 
it's an lvalue
well, at least, the raw literal doesn't
but it'll decay to that const char* rvalue as soon as you try to assign it like that, I think
 
@DeadMG Great. So now we have two hunches. Spelled out at length.
 
9:04 AM
lol
 
Does any compiler have a verbose mode or something?
I would love to see what the compiler is "thinking" as it looks through the source code
Like "treating value as a prvalue" or something
 
By the way both this and that were completely ambiguous to me (I don't have a clue what 'it' and 'doesn't' (doesn't what?) refer to)
 
if you want 100GB of output, sure
 
@Insilico gcc has several -fdump* options. Anyways, rather look up the specs. Someday. @work now
 
@sehe "it", the raw string literal, "doesn't" decay to a pointer
 
9:06 AM
@DeadMG You may be right, it would be a const lvalue. But it would decay only as a function/template argument, right?
 
no
the decay takes place in practically any context
as far as I'm aware, the only times when it doesn't decay are when taking a reference to it
 
9:19 AM
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 :(.
 
@KillianDS he probably thinks the same about you^^
 
@bamboon Meh, don't care, I'm not a good programmer anyway :), didn't study programming either. He did however.
It wouldn't be that bad if the abstractions were useful, but I have to add something and the only result it manages is making me copy-paste a lot
 
Huh, I somehow starred this. That wasn't very useful. Sorry for that
 
@KillianDS: Well, 20 classes doesn't sound too bad depending on what it is
 
@Insilico a framework for a simple daemon
20 classes does sound like quite a lot. Especially in python
 
9:31 AM
@sehe: Ah, I can't read
 
sbi
@sehe FTFY.
Morning, BTW.
 
@sbi Thanks. Morning to you too
 
Does std::string::length() return the number of characters including or not including the NULL terminator?
The standard simply says "Returns: A count of the number of char-like objects currently in the string."
 
@Insilico so it doesn't include the null terminator :)
 
VC++'s implementation of std::string gives me the length without the terminator
 
9:34 AM
technically, it isn't even required to have the terminator
at least not in 03
 
So the "char-like" term is the key phrase here? :-)
 
the null terminator is an implementation detail of C strings
yeah, I suppose
 
@jalf: How can c_str() work then?
It seems to me the only sane way to implement std::string is to use null-terminated strings
 
@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
 
@jalf: How do you know when to free the string?
 
9:36 AM
@Insilico not sure. :)
 
I did say "sane way". :-)
 
no, you added that later. The original question was just how c_str could work ;)
you're right, the only sane way it can work is by storing the null terminator in the std::string buffer
 
> It seems to me the only sane way to implement std::string is to use null-terminated strings
Null termination is confusing as hell anyway
 
50
Q: Is string::c_str() no longer null terminated in C++11?

MankarseIn 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...

 
2 mins ago, by In silico
@jalf: How can c_str() work then?
I don't see anything about "sane" there ;)
 
9:37 AM
Fine.
 
C++11 fixed it ^^ allthough the standard made the specification very implicit. It confused the hell out of us when we got that ^^ question before.
 
"How can c_str() work in a sane manner then?"
 
@Insilico See the linked Q/A
 
@Insilico "by requiring std::string's internal buffer to always have room for the null terminator"
 
> And both c_str and data are required to be O(1), so the implementation is effectively forced to use null-terminated buffers.
 
9:38 AM
Ah, I see.
Thanks @sehe
 
C++03 just allowed a not-so-sane implementation
 
Searching SO always helps. Rank on votes :)
@jalf Indeed
 
@sehe: Yeah, the "relevance" tab isn't very good at giving me things that are relevant. :-)
 
If you want that, really, just use std::vector<char> which is close anyway
 
std::vector<char> is for binary blobs. :-)
 
9:40 AM
@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
 
I use wchar_t for storing characters.
I know that a "character" might actually be two or more wchar_ts in UTF-16 but whatever
It's the best I got until everyone uses C++11
I hate the fact that if I log into Gmail I'm also logged into YouTube
 
@Insilico char is equally good. wchar_t is just more convenient with external API's in case of UTF16.
 
@sehe I tend to use unsigned char for binary blobs, and char contiguous storage of characters :)
 
@sehe: It is, but on Windows it uses UTF-16 (or at least I think it does)
 
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))
 
9:44 AM
@jalf: unsigned char probably is better for binary blobs instead of char
Since I probably would have to do bitwise arithmetic on it
 
@Insilico Depending on what you choose. But yes, Windows favours UTF16. Name another OS doing the same?
 
@sehe:
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?
 
@Insilico wchar_t is a datatype. It doesn't imply character sets nor character encodings
 
@sehe: Correct, but on Windows it means "UTF-16"
I'm asking what it is on *nix systems, typically.
Or is my question about *nixes completely stupid? :-)
 
@Insilico Typically, UTF8
 
9:48 AM
I figured as much
 
@Insilico On windows, it is only convention, also. So, no, "On windows it means UTF-16" isn't very accurate
 
@sehe on *nix systems, char is utf8, and wchar_t is utf32, afaik
usually, anyway
 
@sehe: Yeah, I was being sloppy with the language
@jalf: Looks like I'm using a typedef for this one then
 
@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?
There are no kernel calls taking wchar_t, AFAIK
 
@sehe: Yeah. When I'm talking to the operating system's API, what character encoding am I expected to use?
Oh okay.
 
9:51 AM
So yes, when on UNIX, you'd prefer to use UTF8 unless you don't mind continuously converting back and forth
 
@sehe: I'd rather not have to do that. :-)
 
@sehe I was only talking about the convention
but @Insilico was trying to figure out what char and wchar_t typically 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
 
Yeah I should've asked "When calling the operating system APIs am I supposed to be using UTF-8 or UTF-16 or what on *nixes and Windows?"
 
@jalf I was asking about what convention, what context
 
Presumably Macintoshes use *nix conventions as well
 
9:55 AM
In my view (which may be incomplete) linux doesn't have a convention for wchar_t
 
@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
 
@jalf That has zero to do with unix, and everything with a compiler implementation. Also, nothing at all to do with text or encodings
 
@sehe Which part of the word "convention" would you like me to repeat?
I know it depends on the compiler implementation
 
@jalf What part of context do you want me to repeat ?! lol
@jalf Compilers aren't bound to a platform.
 
What is it with C++ programmers that makes them want to pretend to be imbeciles?
@sehe no, they are not. I don't think I ever pretended otherwise
 
9:57 AM
@jalf Okay, I missed the part where you said utf32 instead of utf16. Makes sesnse.
 
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
 
9 mins ago, by jalf
@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
 
yeah, I know I should be more precise in this room
3
 
@jalf Agreed. Wew. confusion solved :)
@jalf lol
11 hours ago, by Cat Plus Plus
We're not fair, we're insane.
 
Damn all I asked was what encodings am I expected to use with *nix and Windows APIs. :-P
 
10:01 AM
@Insilico And you got an answer. About two messages in, actually, IIRC :)
The rest was just an awesome display of GIGO
 
@sehe: Yes it was. :-)
Are chat messages included in any data dump?
Just curious
 
@Insilico No idea. I'd not even know what to expect. I'd guess 'no' - as the dumps predate chat and chat is not part of the QA goals, I feel
 
10:17 AM
I guess this doesn't copy the data from the char array to the std::string or does it?
 
@TonyTheLion btw, sizeof(char) == 1, by standard
 
@Abyx yes I know
 
@TonyTheLion yep, it works as you expect, std::string will copy mystr
 
cool, another memory leak I just fixed in my code :)
I wasn't freeing the char* before
 
use smart pointer
or just a vector<char>, it does same malloc and free under the hood
4
 
11:02 AM
@Abyx and it calls the constructors and destructors! malloc and free don't.
 
@Abyx Or std::string :)
 
"std::string" and ":)" don't go well together in one sentence.
 
It's a matter of lowering your expectations first.
 
Hello all :)
Anyone here dealt with openGL es ?
 
Unfortunately, yes.
 
11:09 AM
@TonyTheLion I asked a similar question once.
Depending on how you allocated the char * the string destructor would need to use free(c), delete [] c, or something else.
 
@daknokt umm , were you talking to me ? :)
 
@angryInsomniac well, yeah.
 
@daknok_t :D got confused as you were talking to Tony and Stacked as well !
anyways, do you know any resource that can actually teach you something ?
 
Anyone knows if noreturn is portable (i.e. supported by any decent compiler)?
Like this:
[[noreturn]]
T& operator*() const {
  throw bad_empty_get();
}
 
@angryInsomniac Just use a modern OpenGL tutorial, OpenGL ES is a subset of it
 
11:16 AM
@KillianDS not really , there are quite a few changes from what I know ! NeHe is obviously not suitable
 
@angryInsomniac I explicitly said modern
NeHe is OpenGL 1 and maybe a little OpenGL2 towards the end, with little or no GLSL
arcsynthesis.org/gltut is an example of a modern tutorial
 
@KillianDS can you give me an example of said 'modern' ones ? :)
 
sbi
Oh. It seems the names of room owners are set in italic. Has this always been the case?
 
@KillianDS Thanks :)
 
11:46 AM
@sbi For as long as I can remember.
 
> STL cannot handle single ownership objects, regardless of what type of data it holds.
why?
@sbi lol, I only just noticed that too, because you pointed it out
 
@jalf I don't even know what they're supposed to be :P
 
@jalf lego
 
/me waits for someone to get it :)
 
sbi
11:58 AM
@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)
 
the daltons from Lucky Luke at the bottom right
 
@TonyTheLion you don't think the one next to them might be Lucky Luke then? :p
 
@sbi Actually, I noticed this specific feature a long time ago, although I forgive you for assuming otherwise :P
 
@jalf I don't know, not familiar enough with Lucky Luke
 
sbi
@jalf Huey, Dewey, and Louie.
 
12:04 PM
Simsons, Bert and Ernie, south park, don't see the rest.
 
@daknok_t It is intended to be portable. But no compiler implements attribute syntax yet.
 
oh come on, no one recognized the turtles? :o
 
I just don't know the second line.
 
sbi
@jalf The Bored Panda did.
Chocolate?
 
12:08 PM
Oh noes, they killed Chewie!
 
time for ... ... Super Frustrum Slicing™!
 
sbi
@RMartinhoFernandes To the contrary — they are chewing him!
 
@jalf all of them
 
@RMartinhoFernandes huh? new star wars?
 
12:20 PM
@bamboon because it's so open-ended, subjective and utterly utterly pointless
I guess
at least with current title, and body text
the implied question (how should a 2d array be laid out/accessed) is valid enough, but as presented, it's not going to be helpful to anyone
 
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.
 
@jalf in my very humble oppionen, this is row->major vs. column major. the title is indeed kinda lame
 
sbi
@jalf And with changed title, text, and code the same question might be Ok?? :)
 
@sbi I think so, yes. It's an important consideration to anyone working with a 2d table of datan and who are concerned about performance
and the answer isn't entirely obvious
 
sbi
I was mocking you, @jalf.
 
12:23 PM
@sbi yeah ok, I get it now, very funny ;)
 
sbi
@jalf Too late. You already embarrassed yourself.
 
ok, I just can't read code today :)
 
Man, I hate the implications of the new memory/threading model :(
 
@wilx which implications?
 
It's not as if there's an old one.
 
12:34 PM
Now even simple stuff like updating a data structure in one thread and sending a pointer to the data structure through another thread is not...
Wait.....
I have realized I was wrong.
Well, sort of.
Basically, I want to create some data and send a pointer to that using PostMessage().
But does the PostMessage() do enough of threading synchorinization that it propagates the changes made to memory in one thread to other threads?
 
well, the implication is that "your code might no longer exhibit undefined behavior", which seems pretty reasonable to me
 
I just looked into UPX source code -
void options_t::reset()
{
    options_t *o = this;
    memset(o, 0, sizeof(*o));
    o->crp.reset();

    o->cmd = CMD_NONE;
    o->method = M_NONE;
    o->level = -1;
    o->filter = FT_NONE;
why people write such things?!
 
@wilx no. use SendMessage. it does the synchronization.
 
man
I broke my bone code and I have no idea how
 
@Abyx Uwwaaaa!!
 
12:41 PM
@DeadMG use bisect
 
@DeadMG: Did you facepalm too hard?
 
no
 
we all filled that out already
 
12:48 PM
I'm in the middle of filling that out
 
sbi
@DeadMG No, we did not.
 
you didn't?
 
I would really like to see variadic templates in VC++
@sbi: Fill it out.
 
it was practically posted every five minutes a couple months back when it first went up
well, never mind me then :P
 
Basically anything that I cannot do right now in a non C++11 compiler gets a '5'
Other things that can be satisfactorily emulated gets a lower number
Making 20 versions of a template class for each template arity <<<<<<< variadic templates
 
12:51 PM
at least it's not 2^20 anymore
or do as their Standard lib implementation does- whore the preprocessor
 
@DeadMG: I want to be able to read my code, thanks. :-)
 
lol
 
I don't care if Dinkumware makes their code riddled with eyebleach-requiring style
 
:D
 
But I do for my code. :-)
 

« first day (528 days earlier)      last day (4435 days later) »