« first day (92 days earlier)      last day (4854 days later) » 

1:12 AM
const char* ptr; => Its a read only location for the "ptr" to which it is pointing to. However, we can make "ptr" point to a different memory address. So, is this a "constant pointer" or "pointer constant"?
 
1:24 AM
it's just a pointer to const
 
 
2 hours later…
3:21 AM
Hey people.
I <3 you.
(I'm a master of conversation starters. Say it. Say it now).
 
 
2 hours later…
5:07 AM
@Mahesh useful tip: always read the type backwards.
 
 
3 hours later…
8:36 AM
1
A: Implicit conversion : const reference vs non-const reference vs non-reference

Chris HopmanThe problem is that the implicit conversion from a to a B object creates an rvalue. Non-const references can only bind to lvalues. If B had a default constructor you would get the same behavior if you change the f(a) call to f(B()).

 
9:09 AM
@tina memcmp compares two sequences of bytes (both of length n), whereas strcmp compares two sequences of chars until one of them hits a nul-terminator.
@JohannesSchaublitb Why did you delete your answer?
 
9:31 AM
Damn. My quicksort implementation recurses 1000 levels deep for only half a million elements. That’s a factor 50 too many :(
@DeadMG BTW, any follow-up on your task to implement TSP using A*? I’d really like to know how that worked out
 
@FredOverflow because he was first to answer
and I just used a more explicit formulation, but apart from that my answer was just the same as his, so I saw no reason in keeping mine :)
 
@JohannesSchaublitb Noble.
 
Die Ritter der C++ Tafelrunde
Templates sind unser Schwert!
Dazu passend erstmal ne Ritter Sport essen...
> Strictly speaking, you cannot create lvalues or rvalues at all, since the value-category is an attribute of expressions (compile time), not objects (runtime).
 
"It compiles just fine on my MSVC++ 10 Complier." <- dude, why aren't I'm using MSVC++. it wouldn't give me silly error messages!
@FredOverflow i completely agree to that statement
 
9:42 AM
It's a comment to this answer:
1
A: Implicit conversion : const reference vs non-const reference vs non-reference

Chris HopmanThe problem is that the implicit conversion from a to a B object yields an rvalue. Non-const references can only bind to lvalues. If B had a default constructor you would get the same behavior if you change the f(a) call to f(B()). -- litb provides a great answer to what is an lvalue: Stack Ov...

Always trying to convert the non-believers, aren't we :)
 
what I find sloppy is "The problem is that the implicit conversion from a to a B object yields an rvalue. Non-const references can only bind to lvalues."
because the conversion is not even considered. but I guess as an answer that's alright
 
Generally speaking, conversions yield temporaries, not rvalues. Right?
 
somewhere the pedantry starts to get annoying
/me eyes @Tomalak
@FredOverflow when you convert to a non-class/non-ref type, you won't get temporaries
 
@JohannesSchaublitb Right.
 
the spec says so at one place, overgenerally, but that's a defect not yet repaired
so int(x) doesn't really create a temporary. it just creates a value, and the expression is then an rvalue that yields that value
 
9:46 AM
In C++0x, int(x) is a prvalue, right?
 
I love the new value categories, they make total sense once you get used to them.
 
saying "the implicit conversion from a to a B object yields an rvalue." is fairplay though, IMO. an alternative way would be to say "the implicit conversion from a to a B object creates a temporary regarded by the reference binding as an rvalue."
 
By the way, when will we stop saying "C++0x" and just say "C++"? When the new standard is done? When all major compilers support it? When the 4th Edition of TC++PL is published? When the standard after C++0x enters its final phase? :)
@JohannesSchaublitb ...but there is no such expression...
 
@FredO Unfortunately the distinction is kinda important until there’s major adoption of 0x
 
9:50 AM
the problem is that various paragraphs create temporaries (that of course then do not correspond to any expression) that are then forwarded to reference binding or other initialization rules, which assume that they have to do with expressions, and thus use rvalues/lvalues to make up their rules.
 
for example, most programmers simply cannot use 0x yet since they need to support at least a few recent compiler versions into the past, e.g. everything back to GCC 4.3
 
@FredOverflow the DR that added fixes for this is open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#177
 
What is new is C++0x, and why has have those features been included
 
please forget what I said there, should have read it first :) I mean A a(rvalue) will fail because the first ctor will only accept lvalues.
@FredOverflow I love the new categories too!
 
10:07 AM
Much as I adore the “Engineering a sort function” paper from Bentley et al., their variable names are fudging irritating. pm, pl, pn, es … who the hey understands that?!
 
10:33 AM
@Johannes: I started answer your question but delving into the standard it's messy. did you manage to find out standard-wise why conversion isn't considered for f? (Intuitively because formal param is exact match, but standard?)
 
@Alf yes there is a standard paragraph defining it
 
@MilesRout Watch this video about C++0x.
This one is also pretty good:
(Albeit concepts have been removed from C++0x, but that part is only 5 minutes long)
cdsweb.cern.ch/record/1204845 is more recent, but you have to skip the first 12 minutes, because the actual does not start unteil 12:40 :-)
 
@Alf note that if you only have void f(int); then it works fine. so the conversion to int is fine.
 
10:56 AM
yeah youtube has a couple of good videos about c++0x. I personally like the one with dgregor about concepts the most
 
@Jo So you prefer fairy tales? ;-)
 
hi
 
11:38 AM
Hi Everyone! Is this room about c++?
Of course it was joke :)
 
I'm Stuck, i don't have any idea how to do a parser
 
try to first write a simple recursive descent parser for something simple like infix expressions
 
for example a{b=c;}
 
then advance to using parser framework
 
11:43 AM
and getElement("a").getValue("b");
It is good idea to split the code by ';'?
and then analyze all of the parts?
I don't even know how the parser algorithm should look.
And i'm thinking over 2 days without any idea
 
tokenize first
then lex the token stream
 
You mean String.find_first_of ?
Thenk you for your advice :D
 
no
 
@DeadMG uh, you mean parse? lexing produces token stream, the way i've learned these terms
 
that's why I dislike the terms parser and lexer
 
11:47 AM
:-)
 
tokenizer is a much better name
what you want to do is split the string to be parsed up into tokens
 
If for example you have code like c++ which tokens would you use
 
that pretty much involves looking at every character
uhm, a lot
 
I'm thinking about ; and } :/
 
@DeadMG But tokenize == lex. Parse is distinct
(lex = lexical analysis)
 
11:48 AM
what's easier to think of is what separates tokens
spaces and newlines
if you come across a space or a newline, the token is finished, time to start a new one
if you find a meaningful character e.g. '{', you know the previous token is finished, that character is a token in it's own right, and the next character starts a new one
unless it itself is whitespace
 
I'm not too good at english, but do you mean i should tokenize/split by new lines whitespaces?
 
let me show you
just sec
 
Oh i undersand now
i should think what separates tokens: space/newlines
then get value of begin token and end token or what? xP
 
that's a tokenizer I wrote
 
Wow, you're fast :D
 
11:53 AM
not right now
I already had it lying around
most of the code deals with my own Token class
and I stored them in a specific fashion
you could cut most of it if you wanted to just store them in a stack or stream
 
But i;ve lost at line 4, where the heck is declared arg?
 
I always get the willies when I see a non-formal tokenizer, sorry :<
 
oh
it's declared above
that's a for loop inside the file -> filename container
where arg is a std::pair<const std::string, std::string>&, and the first one is the file name, and the second one is the file contents
I wrote a quick UI in C# and the parser in C++, much easier that way
@Konrad: On earth is a non-formal tokenizer?
 
@DeadMG One that doesn’t model a finite automaton describing all the tokens.
 
I have a LOT of tokens
 
12:00 PM
Doesn’t matter
 
somewhere I read that lex is a superset of tokenize. but I haven't really understood it. They said that tokenize just means to split an input, but lexing means to split the input according to the internal structure of tokens
 
For example, the whole premise of “split on whitespace” is flawed – it may work for certain grammars but it makes the whole process non-obvious
 
maybe i misremember it
 
well I have a specific grammar in mind and have no need to split on anything other than whitespace
 
@Jo Perhaps what they meant is that a tokenizer basically splits. A lexer can do much more than that, e.g. parse individual token values, generate recover points for error recovery and so on …
@DeadMG In that case, fire away soldier.
 
12:02 PM
what I'm saying is
non-formal has a place
 
@DeadMG Admittedly, it does
 
@KonradRudolph ohh i see now
 
perhaps I’m just so radical because I’ve seen the parser code of Paul Vick’s hobby VB parser (Paul Vick being the ex-lead of the VB team)
it’s horrible code
 
lol
did he use goto to feel at home?
 
@Jo As a VB fan, I resent that comment
but yes, he did. >:(
 
12:05 PM
:P
 
12:25 PM
so then
to work on DeadMG++ or game?
 
@DeadMG What kind of game?
 
hide and seek in space with lasers
in short
 
@DeadMG There is hardly any matter in space, so you wouldn't have any chance to actually see the lasers, right? (On earth, you can use cigarette smoke to make lasers visible.)
 
pfff
those are realistic sciencey lasers
not cool pew pew laz0rz
you know
it occurs to me that the smart thing here is that actually, different meshes need different shaders
oh well
 
12:42 PM
@FredOverflow if that was correct then one shouldn't hear the "swoooooosh" sound of spaceships passing, either. but i heard that in lots of movies.
 
@AlfPSteinbach Exactly. That's why 2001 is the only real space movie :)
 
lol
man
my FPS is way too low
I used to get 1500, now it's 8-900 rendering the same scene
 
@FredOverflow Dude. Firefly.
no sounds in space
 
@konrad: the sound of silence
 
ok
note to self: finish game before optimizing it
 
1:21 PM
question
can meaningful buttons exist that are just text and no image?
 
1:31 PM
@DeadMG What do you mean? “OK” buttons?
 
but would you want the button to have just text?
just thrown on the image
 
For buttons like OK and Cancel, I prefer text
graphics are a bit disruptive here, aren’t they?
 
well, you have to display the limits of the button
else how do you know where they begin and end?
 
@DeadMG Ah that. Good question
you’re right then
Of course, an alternative is to display just the text, no border, sort of like a hyperlink
but I don’t like that
 
1:34 PM
the difference is that hyperlinks are surrounded by normal text
 
i don't understand. what is the problem of displaying icon next to button text?
 
gotta go, make some lunch
 
no reason why not
but that also involves the use of a texture
 
oh i see now. it's some opengl stuff
thought it's some kind of UI question
 
direct3d, but point's the same
question was about whether or not buttons that are pure text make sense
 
1:37 PM
ohh
 
0
A: can we write this in C++ switch ?

FredOverflowAlternative, more terse solution: #include <cstring> // ... if (strchr("eioua", i)) cout << "vowel"; if (strchr("+-/*%", i)) cout << "operator"; Note that strchr considers the terminating zero part of the string, so i should not be 0.

 
@JohannesSchaublitb still on the lexer>tokenizer thing...
4
Q: lexers vs parsers

NaveenAre lexers and parsers really that different in theory ? It seems fashionable to hate regular expressions: coding horror, another blog post. However, popular lexing based tools: pygments, geshi, or prettify, all use regular expressions. They seem to lex anything... When is lexing enough, w...

 
2:12 PM
@DeadMG hope he doesn't take your answer as offense. +1 from me.
 
2:25 PM
what answer?
oh, to the linked list thing
the fact is that he's got it so completely wrong, he needs to get a book
 
2:54 PM
i wonder about all this associative approach to understanding. it's like they don't trust reasoning. must all be memorized cookbook recipes for this variant and that variant, and approach to any novel thing is to just associate wildly
 
3:09 PM
Alf, I don't get what you mean
 
lol @Alf you are talking secret
hm i don'T undersstand this: why do some messages in chat have big pictures next to them and others have small?
 
3:23 PM
@JohannesSchaublitb whatever fits in the vertical size of the message
 
5
Q: What the heck is this C++ syntax called?

nessupI see it everywhere in constructors in Qt applications, but I don't know what it's called. I'm trying to find docs about it. Browser::Browser(QTextBrowser& textBrowser, QObject* parent /*= 0*/) : // <- What m_textBrowser(textBrowser), // <- is QObject(parent) // <- this stuff? { } ...

Another "strange colon" question (no, not a case for the doctor). Vote to close, please.
@JohannesSchaublitb My first guess would be that you get a large picture if you haven't said something in a while. But I cannot substantiate that with any data :)
 
let me demonstrate:
for this message, i elected to have large icon
it's very simple
you make a wish
and jeff fixes
 
i
have
a
large
icon
 
@Alf You should have let them figure it out themselves. It becomes pretty obvious when you look at a few messages …
 
lulz
@KonradRudolph i compared the message of Alf and the one of DeadMG, both having 3 lines. but they had different sized icons
 
3:30 PM
Boy, Bjarne has become old (and wise, of course)...
 
now i see though that it wasn't a single 3 lines message but 3 single messages
 
@JohannesSchaublitb Which ones, specifically? I don’t find ones which exhibit this
@Jo Ah.
 
@FredOverflow lol
this
big??
 
@Jo No … see here:
1 hour ago, by Konrad Rudolph
@DeadMG Ah that. Good question
and following
 
@KonradRudolph see your icon got bigger when you pasted that quote
 
3:32 PM
Subsequent messages, each one line, still my pic is big
 
but if you do a single 3 lines message your icon stays small
 
a
b
c
huh
 
There must be some rand() calls sprinkled into the algorithm that determines the picture size...
 
3:36 PM
Weird indeed
perhaps we should file a report?
 
i think it is based on pixel height instead of line count
 
I’ll trop Marc & Benni a tweet
 
there's less inter-line space than inter-message space
 
3:47 PM
well
you'd think considering my chat style
I'd frequently get large icons
but no
only got a large icon on the fourth line
 
I know, I'm late to the party
 
i think i have a theory
 
Chat transcript only shows small avatars
according to Benni
 
a
a
a
oh that should have been three separate messages. darn
 
3:57 PM
/away lunch.
 
4:19 PM
0
Q: OpenMP: Get total number of running threads

Konrad RudolphI need to know the total number of threads that my application has spawned via OpenMP. Unfortunately, the omp_get_num_threads() function does not work here since it only yields the number of threads in the current team. However, my code runs recursively (divide and conquer, basically) and I want...

Any takers?
 
4:45 PM
sorry Konrad
use the PPL myself
 
@DeadMG Not platform independent, but otherwise very well designed
 
fortunately, I'm only interested in programming for Windows
 
Not caring for platform independence makes programming in C++ much easier
unfortunately, it’s a no-go for me
 
5:03 PM
@KonradRudolph iirc, OpenMP reserves itself the right to use the optimal number of threads according to the number of available cores. Though I'm not sure if you can change this.
 
@jweyrich Only if that number isn’t overwritten – which is done by me via the num_threads directive
 
@KonradRudolph so why don't you just increment a counter to keep track of the total?
 
@jweyrich Hmm. It’s kind of difficult to keep this variable up to date, though, since the function recurses. Would need to be an extra parameter that points to a shared location …
@jweyrich Still, probably the best/only solution …
If you put it as an answer, I can upvote it ;)
 
@KonradRudolph ok. I'm writing it.
 
5:30 PM
Please check out my proposal guys
 
@RobertPitt No offense, but do you repeat this same message on a daily basis? sigh
5
 
jqeyrich, i posted the same link twice within 48 hours, its not exactly harmfull as im helping the SO Network grow with my proposa
proposal
 
@RobertPitt I'm not saying the inverse. But it was indeed a rhetorical question.
 
most of us already committed to it anyway
 
5:51 PM
it can also have negative effects if you travel around collecting followers like that
because people who aren't really going to later contribute but are still interested will sign up. the beta starts, noone looks by, and the site won't be created. no good
@RobertPitt BTW I like your glasses xD
 
thanks dood.
And thats why i have only targeted languages that are relavant such as C++, Javascript, PHP, C# /.NET
 
6:08 PM
@jweyrich Amazing, this worked, and was incredibly easy to implement. It’s still insanely hacky but – hey? Who cares? I’ll write a follow-up to my question.
 
@Konrad: What question?
 
Whenever there is an error in the compiler should be able to find it. If something happens at run-time then it is an exception. So are run-time errors different from run-time exceptions ?
Whenever there is an error, compiler should be able to find it. If something happens at run-time then it is an exception. So are run-time errors different from run-time exceptions ?
 
yes
your program can exhibit errors which are not thrown as exceptions
such as any undefined behaviour
if you de-reference a null pointer on Windows, you will receive an access violation, which is a run-time error, but you can't catch that as an exception
well, you can, but not within Standard C++
 
So, all seg-faults are run-time errors as per Standard C++
 
@KonradRudolph great! Feel free to amend my answer, if you like.
 
6:18 PM
no, they are undefined by the Standard
and your implementation is free to throw an exception if it likes, or raise SIGSEGV, or pretty much anything it likes
however, run-time exceptions are clearly documented and the situations that throw and catch are well-defined by the Standard
 
ah ok
 
@DeadMG: you know they have comment upvotes so we don't need to comment with "+1", "yes!", and "agreed" :P (or did you comment just to attribute the downvote? but that's another story altogether)
 
lol
what, on that question about std::copy?
If I posted "Agreed", then it would likely be construed as agreeing with the answer
the purpose of the comment was to suggest that I was agreeing with you, not him
more importantly, I very rarely downvote with no explanation
it just so happened that you already posted why his answer sucked
 
If someone downvotes, should provide an explanation. Beginners like me will know from it. Just downvoting isn't going to help me or any one
 
6:24 PM
exactly#
 
@DeadMG I meant including a @reply; I often see silly comments like "@user: +1" or "@user: agree"... do people just not realize they can vote on comments?
 
@FredNurk @DeadMG please, read my comment on that answer.
 
I did
oh wait
 
it was meant to @KonradRudolph too.
 
@jweyrich: I must be looking for your comment in the wrong spot; link?
 
6:40 PM
 
anyone feeling adventurous? "how is babby^H^H^Hlocale formed?"
 
A quick test with overlapping also reveals it optimises to memmove.
Oh boy, these compilers are smarter than I thought.
 
that's done in the library rather than the compiler optimizer
usually; because it's easier
though when you do get a optimizer that handles generic for loops the same way, it can work in more places, i.e. naive code :)
 
@FredNurk how so? A precompiled library can't change according to the level of optimisation you choose, so it's still a job for the compiler optimiser to choose the proper method.
 
6:55 PM
Anyone here?
 
@jweyrich: didn't say pre-compiled, std::copy is re-compiled in every TU that uses it
and more than once, owing to different template parameters
 
@FredNurk but the library can't decide about it unless it has 2 distinguishable prototypes (e.g.: type deduction). The optimisation is made by the compiler, mainly because it has prior understanding of how the standard library operates.
 
have you ever seen how std::distance changes its behavior depending on whether you give it a forward iterator or a random access iterator?
it is much less costly to do these optimizations in the library than the optimizer, at the expense of having to re-apply them on every use – or require everyone use the library function (e.g. std::distance, std::copy)
 
7:19 PM
@FredNurk that's exactly my point. std::distance "does" such optimisation because it has two or three distinct signatures/definitions. The type-deduction will chose one over the other. That's not true for the optimisation that happens in std::copy (for streambuf iterators). I think SFINAE isn't capable of providing that too, but I might be wrong.
 
@jweyrich Why not? The STL (yes, I called it that) can (and does) disambiguate using traits
I’m almost certain that such a trait can be written
 
@KonradRudolph You're saying that it's possible to use SFINAE to check whether the destination iterator overlaps the source range? I'd love to see that.
 
7:42 PM
@jweyrich Uhm … forget that. On the other hand, the compiler/optimizer usually can’t see that either, right? This must be a run-time decision since the range can be dependent on user input
or not?
 
well
if you get passed different types of iterator, you know they don't overlap
 
@KonradRudolph the std::copy case seems to be a good candidate for optimisation because the compiler has all the required information to check whether the involved memory regions overlap.
 
@jweyrich no, std::distance is not overloaded like that, it calls a hidden implementation detail function which is overloaded on iterator_category; this is compile-time programming, and the same method can be used in std::copy to distinguish raw pointers from everything else, and then (with some implementation-specifics) pointers to POD from non-POD
the compiler cannot check whether the regions overlap in most cases, that is still done at runtime
 
@Fred Nurk: That's not entirely true
 
but you can write it in such a way that the check is an inlinable function, which a partial evaluator can use in the rare cases where it can be determined at compile time
 
7:49 PM
the Standard provides a type trait for is_pod or trivial_destructor or something like that
I've used it in the past
 
not in c++03
 
yeah
but who cares about that?
I appreciate the difference between C++0x and C++03
but it's in TR1
 
anyone talking about real implementations in 2011
 
TR1 which was now six years ago
 
@FredNurk std::distance uses __gnu_cxx::__distance (strictly talking about GNU), which are the specialisations I was referring to.
 
7:51 PM
and I believe that boost offers such a type trait too
 
@DeadMG published != fully supported by compilers
 
what compiler do you use that doesn't support TR1?
 
@jweyrich: then I misunderstood "std::distance 'does' such optimisation because it has two or three distinct signatures/definitions."
 
GCC and Visual Studio have both supported it for a number of years
 
@jweyrich: I did already mention calling the internal overloaded function
@DeadMG: I forget, you are in school and can use the latest compiler on every project always
 
7:55 PM
there's a difference between I get to use a C++0x compiler, and getting to use a TR1 compiler
 
for many people, the idea of using tr1 has only become feasible in the last few years, even though it's 3x older than that
 
ah
so using TR1 is feasible for many people, then?
 
I can't believe you're arguing with me because I said "some compiler-specific knowledge" or such instead of "tr1"
just like on SO, this kind of minutia isn't helpful, yet I keep getting drawn into it
 
@FredNurk This kind of optimisation doesn't apply to what happens in std::copy. We can talk during days about specialisations, but it cannot be done for the case which started this debate. And I reaffirm the std::copy optimisation is performed by the compiler in the sense that it explicitly replaces the underlying function call according to each scenario.
 
no
I'm arguing with you because you're suggesting that using TR1 isn't feasible in the general case
a statement with which I disagree
 

« first day (92 days earlier)      last day (4854 days later) »