« first day (372 days earlier)      last day (4568 days later) » 

9:01 AM
@RMartinhoFernandes No, someone edited it out. That guy even called the person who posted the solution an idiot in the comments to his answer before realizing he'd solved the problem.
 
@RMartinhoFernandes I did see an idiot.
@RMartinhoFernandes This is officially the stupidest post I've seen on SO.
 
I think I've seen worse.
 
I usually ignore them..
 
@StackedCrooked You must've missed this one
0
Q: Comparing to items in an Array c++

Lexiconalright guys, this should be an easy one... I have an int array and I want to see if the the numbers in the array are in succession. For some reason when I do this (below) my array goes from int values to ascii and gets all funky and doesn't work. Any suggestions would be greatly appreciated. ...

> my array goes from int values to ascii and gets all funky and doesn't work
 
He somehow concludes that std::set can't store more than 50 objects objects. And he immediately starts blaming the standard library. This is moronic.
 
9:06 AM
1 hour ago, by FredOverflow
> my array goes from int values to ascii and gets all funky and doesn't work
 
@Praetorian Nah, that guy is just a confused beginner. He would be an idiot if he started blaming C++ for not implementing arrays correctly.
 
Well, C arrays kinda suck.
 
@StackedCrooked What was funny about the std::set guy was that he blames the standard library and then gets all indignant and pissed off when people start downvoting him
 
@Praetorian Exactly. That's the stupidest thing to do if you are trying to get help.
That's the stupidest thing to do.
Fixed.
 
> I'm not doing curls with my laptop. I'm putting it on my lap, which can handle a little extra weight being put on it. What it can't handle however is being scalded by a poorly ventilated brick of heat.
 
9:19 AM
His question is interesting though. A simplified example would be storing std::string objects in a std::set with a comparator that compares by string length. If you want to be able to add multiple strings with the same length then how would you implement the comparison function? In the past I would have differentiated by address, until I learned that this is UB.
 
Think about why you would want to do that.
How relevant is the comparator for code outside the set?
 
I think the question in that case is Why do you think you want an std::set?
 
Because that sounds more like a job for an std::multiset since the comparison can produce collisions easily
 
@RMartinhoFernandes The comparator is defined on the set, not on the object.
@Praetorian Good point. I recall using a multiset in one of my programs for a similar situation.
 
9:27 AM
If you want a set, the comparator is only relevant for the set code. Your code won't be using it directly. So where does this "comparator must compare by length" requirement come from?
 
@StackedCrooked Not sure what you mean by that. If you want an std::set<std::string, StrLengthComparer> you need to define the comparison predicate for the string object, since the default operator< for std::string is lexographical comparison, not length
 
You want the comparator to provide the appropriate uniqueness semantics. If length is not what makes an object unique, why are you using it in the comparator?
 
@RMartinhoFernandes This allows you to order by length.
 
But doesn't give the uniqueness semantics you want.
 
No so you need to combine it with a second or third property to make it unique. Like a composed-key in a database table.
In case of string you could implement it as:
if (left.size() != right.size())
{
    return left.size() < right.size();
}
else
{
    return left < right;
}
 
9:33 AM
Right, because there's one more thing that makes a string unique in your example: its contents.
 
Indeed.
 
@StackedCrooked I'm curious why you said earlier differentiating the strings by address is UB. As long as you don't modify the strings after insertion, that should work, shouldn't it?
 
@Praetorian I just looked it up again and apparently it is "unspecified".
 
What is unspecified?
 
The result of comparing pointers that do not belong to the same array is unspecified.
 
9:35 AM
Hmm, didn't know that. But pointers are just integers, no?
 
Other than == and != of course. Those are always defined.
 
However std::less is defined behavior. And it is implemented as return t1 < t2;
 
@StackedCrooked No, it's implementation-defined.
 
in c and c++, pointers are abstracted a bit away from the machine. underneath it all they might just be integers, but it depends on the compiler
 
Well not so much a 'no' as that's not required though.
 
9:38 AM
@LucDanton Ok. I just saw this implementation in the GCC headers on my machine.
 
the standards explicitly try to steer clear of demanding any particular representation for a pointer; they just say what operations must be available for one (or two)
 
@StackedCrooked Right. You're still not allowed to compare unrelated pointers!
 
@LucDanton Is using unspecified behavior not allowed?
 
But std::less is required to provide a total order for pointers.
operator< isn't though.
 
@StackedCrooked Unspecified is fine most of the time, undefined is not.
 
9:40 AM
unspecified is about half a step from undefined, though
 
Note that providing a portable ordering for pointers is as simple as using (std::intptr_t)lhs < (std::intptr_t)rhs (that's for data pointers).
 
But unspecified here is not fine. It does not mean it has to provide a strict weak ordering as required for std::set.
@LucDanton Isn't std::intptr_t optional?
 
@RMartinhoFernandes I'm not claiming that it is.
 
@RMartinhoFernandes Isn't std::less for full implementations?
(I.e. I dunno)
 
What do you mean by full? Hosted?
 
9:41 AM
@cHao It means that it is platform specific.
 
@StackedCrooked not just platform specific. compiler specific. and the compiler doesn't even have to have clear rules about what it does.
it just has to do something consistent
 
@RMartinhoFernandes That would be the appropriate nomenclature. Unless I meant freestanding, I forget which is which.
 
Ah right.
But even in a hosted implementation, std::intptr_t is optional :P
Damn, so many mistakes in that message.
 
But that's just as beside the point (regarding portability) as freestanding/hosted :(
 
@cHao I was going to write compiler specific. But then I thought that GCC on Linux might behave differently than GCC on Mac or GCC on MinGW. So I choose the word 'platform' in a rush. Unfortunately, an incorrect choice.
It think the cartesian product of compiler, platform, architecture and possible a few other settings.
 
9:46 AM
Well, I never claimed std::less was portable :)
 
@RMartinhoFernandes I think that would be a valid claim.
 
gcc on mac is a different compiler than gcc on linux, imo. :) closely related, of course, but it has different rules it has to follow
 
@RMartinhoFernandes Oh, I was implicitly comparing casting to std::intptr_t to std::less. As in, ''if for some reason you don't to use std::less to order pointer, then there's this".
 
According to the IBM XL compiler docs cstdint does not contain an intptr_t but it does contain an intintptr_t
 
@LucDanton I think you can also reinterpret_cast stuff for this.
 
9:47 AM
An integral type large enough to hold values of intptr_t? How convenient.
 
Wait, that's what you did.
Silly C casts.
 
You have a point though, without an intptr_t you can resort to reading the object representation I suppose.
 
Right, you can reinterpret_cast back and forth between pointers and a large enough integral type.
So, if you lack a intptr_t, you can always use intmax_t and hope it's big enough.
If sizeof(void*) > sizeof(intmax_t) you're screwed.
 
Let me check the docs.
 
If I were to define this function: template<typename T> bool operator<(T * lhs, T * rhs) { return std::less(lhs, rhs); }, would this allow me to use operator< on pointers? (I'm also not sure whether it would lead to infinite recursion.)
 
9:50 AM
§5.2.10p5
@StackedCrooked You can't define operators for non UDTs.
 
Ah, silly me.
 
@RMartinhoFernandes According to Wikipedia, intptr_t is part of stdint.h, so it should be available in cstdint also
 
@Praetorian Yes, that's where it is located, if available. It's optional.
Hmm, but I'm still not sure about the reinterpret_cast thingy. Pointers must be roundtrippable through a suitable integral type, so I think you can derive that the each integral value will uniquely identify a pointer. However, I see no guarantees for assert(reinterpret_cast<suitable_int>(p) == reinterpret_cast<suitable_int>(p)).
 
Right, so my interpretation is that casting to an integral type is implementation defined in general, and that it's defined for intptr_t. I had to take a trip to the C Standard though.
So you can read the object representation if for some reason you want to stick to defined behaviour. In all cases I have idea what the resulting ordering is like.
 
@RMartinhoFernandes Yep, §18.4.1 lists it as optional
along with all int*_t and uint*_t, why on earth would those be marked optional?
 
9:57 AM
Why doesn't the spec simply require the built-in "operator<" on pointer types to yield a total order? (Sorry that I keep beating this almost-dead cow.)
 
Weird architectures?
@Praetorian The int_leastX_t series are good though.
Because on architectures where CHAR_BIT != 8 it's impossible to get a int8_t type, but you can certainly have a int_least8_t.
 
@StackedCrooked What are the semantics of that though?
 
@RMartinhoFernandes They are, but also very verbose
@RMartinhoFernandes Good point, I forgot TI does exactly that for stdint.h for programming their DSPs
 
@LucDanton The same as std::less. A different way to phrase my question would be: Why can operator< not be implemented in terms of std::less.
Instead of the other way around.
 
Oh, I was looking at the perspective from C.
 
10:01 AM
Because std::less is not required everywhere?
 
I see std::less<T*> as a specialization to make pointers work with maps and with no attached semantics, much like hashing.
 
Right, call it "an opaque total order".
 
@RMartinhoFernandes Don't require operator< everywhere as well then..
 
Is it even required that where p < q (for T *p, *q;) is defined, assert(std::less<T*>()(p, q) == (p < q))?
 
I'm pretty sure that there is no other requirement than to make the order work for maps.
 
10:06 AM
Right, so a conforming implementation could actually have operator> work for all pointers and implement std::less as p > q.
And std::greater the exact same way.
Sometimes I feel an urge to write a compiler that actually behaves in such crazy ways.
 
The infamous "C++ implementation from hell".
Where each appearance of a string literal yields a different address!
 
We should make a list.
 
@RMartinhoFernandes I looked this up, the standard says std::less::operator() must return x < y §20.8.5p5 So such a funky implementation would be non-conforming
 
@Praetorian That's the general case, which would not work for arbitrary pointers. std::less<T*> is special-cased.
 
> For templates greater, less, greater_equal, and less_equal, the specializations for any pointer type yield a total order, even if the built-in operators <, >, <=, >= do not.
> Although Outkube sources admitted the site required little oversight (...) the site does employ moderators to ensure threads stay as active and idiotic as possible.
 
10:20 AM
Alt-Tab in Windows 7 sucks
 
why?
 
Works fine for me.
 
When I wait a quarter of a second or so the iconic display drops to bottom of z-order. and doesn't get back on top again. it's just noise everywhere on the screen
it sucks
big time
 
Sounds like a bug.
Or something to that effect.
 
Can you link to a comment on a SO question?
 
10:22 AM
@StackedCrooked Yes. But you need to obtain the comment ID.
You can get it from looking at the DOM, or use a userscript.
20
Q: SE Modifications -- Username autocomplete in comments, inline revision source, and utility links

Tim Stone Screenshot About This userscript adds four main features: Various utility links on posts and in the top bar Inline viewing of post revision source Markdown on the post history page Links on comment timestamps for linking to specific comments (with enhanced "link-ability" for people w...

 
Anyway, our talented programmer who claims that std::set doesn't hold more than 50 objects now claims that it takes 13 seconds to clear a set containing 4000 ints.
-4
Q: C++ ordered set implementation besides std::set

VladpIs there another good library with ordered set except std::set? I'm using std::set now, but it's too limited: I have two types of objects (derived classes) and when I'm inserting them as their base class the set only accepts or 50 objects of the first type or 1 of the second type. It is seems tha...

See the comments on the first reply.
My code takes 0.003s to run on my machine. Ideone reports 0s probably because of low resolution of std::clock ideone.com/2cG2M
 
lol
 
How the hell did he manage to make it take 13s.
 
sleep(13000);?
 
Btw, my code was unoptimized.
@RMartinhoFernandes sleep(13);
 
10:28 AM
Or that.
std::this_thread::sleep_for(std::chrono::seconds(13));
Much clearer :)
 
@RMartinhoFernandes It's a way.
sleep for 13 seconds.
 
What's that? COBOL?
 
I think AppleScript has syntax like this.
display alert "Hello World!" buttons {"Rudely decline", "Happily accept"}
set theAnswer to button returned of the result
if theAnswer is "Happily accept" then
        beep 5
else
        say "Piffle!"
end if
 
set theAnswer to button returned of the result OMG this is scary.
 
^ Wikipedia sampel.
I'm trying to make sense of it...
It is grouped like this: set theAnswer to (button returned of the result)
Apparently the return value of display alert is one of two buttons.
 
10:35 AM
So, button returned of the result (I can't even parse that as English), is a "keyword"?
 
button is a variable
The rest is vague.
 
Right, that's what scares me.
 
Me too.
 
I don't understand how result is being tied to the result of which of the buttons displayed by the previous display command was clicked
 
Probably acts like a global variable that is implicitly set?
Kind of like errno?
 
10:38 AM
display alert "Hello World!" buttons {"Rudely decline", "Happily accept"} returned of the result would've made more sense IMO :-)
 
They call it "natural language processing". Ugh.
 
@StackedCrooked Is that how you have to talk to Siri?
 
I once wrote a parser for a constrained natural language.
 
@Praetorian I don't know.
 
It's weird.
 
10:40 AM
- I once met a man with a wooden leg named Smith.
- What was the name of his other leg?
^ Natural language processing?
 
Ah, the parser I wrote was for a much more constrained variant of English.
 
Yeah, I was just joking.
 
It had a few "keywords" I could hang on to.
 
I think I have a plausible explanation
 
My point is that a programming language written in natural language is impossible because ambiguities occur in the natural language itself. (However, I'm not a NLP scientist, so this was probably a dumb remark.)
 
10:44 AM
the first line displays 2 buttons, so the return value is a button, - the one that was clicked. So as @RMartinhoFernandes said, maybe the return value is stored in a global called result. Then you set theAnswer to the button that was returned of the result - i.e. returned by result
 
@StackedCrooked You need context, and more.
 
Good morning!
 
Common sense.
@TonyTheLion Hi there.
 
Is there a win32 api equivalent of dladdr() on Linux?
 
If you explain what dladdr does you can get the "Win32 but no Linux" audience to help :)
(There's always Google though.)
 
10:48 AM
here is what dladdr does
not sure if that exists in Win API
 
@RMartinhoFernandes - it plays "name that symbol" on void*
 
I don't even know what "shared object" means.
 
Ok, but I'm not on the "Win32" audience.
:)
 
not just stack traces
anything :)
 
10:51 AM
Shared object == shared library?
 
Need a link for a i++++++++i UB question.
 
@StackedCrooked - if you compile with -rdynamic with gcc then it includes the main executable itself
@RMartinhoFernandes - this one maybe? stackoverflow.com/questions/4176328/…
 
Thanks. Got it.
 
@TonyTheLion "bug-compatible" heh
 
11:00 AM
Our uber-programmer now claims that clearing the set took 13s because he maybe has a weak cpu. He is either extremely pathetic, or a troll looking for some amusement.
 
You're still watching that?
 
uber-programmer? what's a uber-programmer ?
 
Not really, but I received a notification because he replied to my last comment.
 
who's our uber-programmer?
 
See the comments to his question.
 
11:04 AM
:( Nawaz removed some relevant info I added to an answer of his.
 
lol. he's actually looking for a replacement for standard library classes.
how weak is his cpu? he can't be still using a pentium II .
 
The accepted answer performs operator< on pointer types.
 
Oh, there's an accepted answer.
 
ok I don't like down-voting... but this is an exceptional case.
 
What happened?
I still have one downvote left.
 
11:09 AM
Damn I upvoted his comment and I can't seem to undo it.
 
u used it. it's -6 now. :D
@StackedCrooked just click on the upvote button again
 
@StackedCrooked lol
 
I tried that but it doesn't work.
 
@IntermediateHacker Doesn't work on comments.
 
It's kind of hilarious to see such a comment upvoted. It has ironic value.
 
11:10 AM
lol. :D
 
@StackedCrooked I upvoted his comment too, but intentionally. It is hilarious; since it doesn't gain him rep it needs to be visible in that long list
 
His comment just got another upvote (ironic)
 
Come on, now you're just being mean.
 
yeah i guess. I've asked some pretty stupid questions too.
-2
Q: GUI Development in C# .NET? WHICH TOOLKIT?

IntermediateHackerI am planning to migrate to C# for GUI Development. Earlier I used C++/WxWidgets , C/GTK+ and C/Win32Api for most of my projects. But there is one stumbling block, CROSS-PLATFORM COMPATIBILITY. I like Windows Forms but it seems it isnt fully supported by MONO and will not work properly on Non-Win...

One of my earliest questions...
and my stupidest.
 
In this code I printed the size of the containers to stdout in order to prevent the compiler to optimize the whole code away (without printing the sizes the whole code would basically be a no-op). Was this needed?
 
11:18 AM
I believe the only way to be sure is to depend on input.
A super duper smart compiler could figure out the sizes and optimize everything away.
(I doubt you will find such a thing, but it's theoretically possible.)
 
Theoretically it's certainly possible.
Especially since std::set is a template class so all code is visible to the compiler.
Actually, it should compile it all out.
 
There's memory allocation all over, so it would need to see through that.
It's a lot of code to see through (the memory allocation code).
 
@StackedCrooked I changed your code to call std::set::erase on each element in a loop, since that is what that guy's code was doing. It increases execution time to 3.3s, but still nowhere near 13s
 
@Praetorian "in a loop"?
while (!set.empty()) set.erase(set.begin());
Loops are tricky when erasing.
 
for (std::size_t idx = 0; idx < 4000000; ++idx)
{
    numbers.erase(idx);
}
 
11:22 AM
Ah like that. I assumed iterators.
That will be slower indeed.
 
Ugh, there's a lot of searches (O(log n)) there.
 
And the reason for slowness is in his code.
std::set<int>().swap(myset); clears the set and frees the memory.
Learned this from Koenig dobbs post a few days ago.
 
Not as interesting on a set.
 
@RMartinhoFernandes damn
std::set probably frees the memory with a regular clear.
 
It does, because a set doesn't keep extra memory around.
 
11:27 AM
Yep, silly me.
 
It's a binary tree!
 
balanced tree. not sure if it's binary.
 
Actually, I think you're right.
A red–black tree is a type of self-balancing binary search tree, a data structure used in computer science, typically to implement associative arrays. The original structure was invented in 1972 by Rudolf Bayer and named "symmetric binary B-tree," but acquired its modern name in a paper in 1978 by Leonidas J. Guibas and Robert Sedgewick. It is complex, but has good worst-case running time for its operations and is efficient in practice: it can search, insert, and delete in O(log n) time, where n is the total number of elements in the tree. Put very simply, a red–black tree is a binary se...
> In the C++ Standard Template Library, the containers std::set<Value> and std::map<Key,Value> are typically based on red–black trees
 
The requirements are for logarithmic time, but the base is not specified.
 
11:29 AM
I wonder why hash set and hash map were not a part of C++98.
 
So a ternary tree would be feasible. But the overhead (one extra pointer per node) would probably not be worth it.
@StackedCrooked Were those on the STL at the time?
 
Dunno.
 
Speaking of STL
 
Aarg, that melody again..
I never even finished the game lol.
What does STL stand for in that video? Saint-Luis?
 
sbi
Is it just me or is google.com dead for you as well? Other sites work.
 
11:37 AM
It's the brand of the ocarina.
@sbi Just you.
 
@sbi Could be hostname resolving, router settings, ...
 
Wait, my FF redirects me to encrypted.google.com. You could try that.
 
We once had visitors from Google and the IT boss tried to pull this as a joke claiming google is down.
They ignored him.
 
sbi
Oddly enough, when I clock the link I pasted in above, it works for me, if I type in the same characters, it fails. Huh??
 
Can you visit 209.85.148.106?
 
sbi
11:40 AM
Now it works all along.
I'm puzzled.
 
That's the IP returned ping google.com.
DNS server could be the issue as well.
 
sbi
@StackedCrooked It works now. Might have been my FF acting up. Still, it was strange.
 
google.com works for me, but it's using IPv6 for me
 
sbi
Anyway, thanks for your input, everybody. I will now resume what I was doing when I couldn't reach google...
 
It sometimes happens that I can't visit any website anymore. They all timeout. And meanwhile my torrents keep downloading and online radio keeps playing.
 
11:42 AM
Maybe someone typed "Google" into Google.
 
Who did it?
Track him down.
People that type google into google should be shot.
I think it would be cool if you could perform a broadcast ping message to the internet.
Pinging everything.
I think the net would be down for a while.
 
Ok, hot.
 
12:06 PM
This guy goes a little too fast I think.
 
12:26 PM
In the RGB color space, FF0000 stands for red, right?
 
Right.
0
A: C#: what is the difference between i++ and ++i?

thelostint i = 0; Console.WriteLine(i++); // prints 0 Console.WriteLine(--i); // prints 0 Does this answer your question ?

This answer is awesome.
 
Why can't I find youtube Videos in my firefox cache folder? It works in Opera...
 
@FredOverflow I use DownThemAll to get those.
And the fact that is has 0 total score (8 up, 8 down) makes it even more awesome.
 
@RMartinhoFernandes Too bad Eric's answer isn't the accepted one.
@RMartinhoFernandes DownThemAll sounds like someone drinks a lot :)
 
12:36 PM
@RMartinhoFernandes Hm, not very intuitive. Downloading a Youtube Video with DownThemAll does not seem to be possible without studying some tutorials.
 
I never studied any tutorials.
 
cpx
@FredOverflow I use [this](keepvid.com "keep vid" ) sometimes to get videos lol
hmm
 
Chat doesn't support titles.
 
@RMartinhoFernandes Well, DownThemAll does not recognize any videos on a Youtube site. Strange.
 
Works here...
 
12:40 PM
Where exactly do you click and what happens then? I just get a window with lots of links and pictures on the site, no videos.
 
cpx
It didn't work because i used an extra space. c'mon!
 
@FredOverflow Sorry, no freehand circles.
 
@RMartinhoFernandes There are no get_video links in my window.
 
12:48 PM
But nevermind, I downloaded "Video DownloadHelper" and it works great.
 
No idea.
I can't stop laughing at that useless machine video. It's so silly.
 
what does the machine do?
what does it mean?
 
@JohannesSchaublitb It turns itself off.
 
I'm going to build one.
 
12:53 PM
oh how a deep life cycle simulator machine
 
Or two.
I'm enthralled.
It's just... beautiful.
 
Aren't those machines more or less like an empty main function?
 
They're like coroutines!
 
it's a DOUBLE MACHINE!
 
@StackedCrooked stupid audio glitches
 
1:03 PM
> The resulting project, presented here, is the ultimate in technology for its own sake, a minimal assemblage of parts that, through its one meaningless act of defiance, speaks volumes.
 
1:19 PM
ok
after all that effort and money I went through to go back to university
and now I'm reminded of how much it sucks
 
cpx
oh what happened to the end of world rumor? i can't even remember which day it was.
 
You missed it, it ended a week ago.
 
It started Last Friday.
 
cpx
I remember reading about it in here though
 
But the world started Last Friday. Trust me. Don't let yourself be fooled by those Last Thursdayist ignorants.
 
1:32 PM
Cool I just ordered the last one in stock of a product Amazon.com. It's now unavailable.
 
You're mean.
 
If I didn't buy it then someone else would have bought it. I chose to shoulder the sin so that the other can live in peace.
 
> want to stop smoking? buy a smoking machine! it will smoke for you!
 
Whoa, I paid 30 $ and now I find a competitors product that's only 4$. I'm a fool.
 
That's what you get for being mean :P
You can probably still cancel that Amazon order.
 
1:38 PM
@StackedCrooked What product was that?
 
Probably.
Plastic keyboard cover.
@RMartinhoFernandes It would be cooler if it obtained its energy from burning the cigarettes.
 
@StackedCrooked a stirling engine off that would be pretty cool
I was also slightly disappointed it didn't use any accelerants
 
2:06 PM
anyone know what the Qt::UserRole is for?
 
> The first role that can be used for application-specific purposes.
 
hmmm, but what is 'role' in this case?
is it like to save custom user data or something?
 
2:31 PM
Meh, vim's highlighting is fussing about lambdas.
 
2:43 PM
I've still not quite figured out how I want to format lambdas myself, let alone trained emacs to do it for me
 
for_each(v.begin(), v.end(), [] (int value) {
    do_something(value);
});
^ Is common way to format.
Why does class X require a user-defined copy constructor and copy assignment operator?
Oh I get it. Assignment operator must not take the shared_ptr.
 

« first day (372 days earlier)      last day (4568 days later) »