« first day (286 days earlier)      last day (4660 days later) » 

11:00 AM
The tag is plagued by plzsendtehregex questions.
 
sbi
When your hammer is C++, everything begins to look like a thumb. Steve Haflich #FridayJoke
 
Hmm, I think I'll start voting to close them too.
 
sbi
@KerrekSB PHP has an "explode" function?! Wow. How fitting.
 
@MartinhoFernandes What's worse is that people don't even think about simple string operations! They immediately jump to regular expressions! Just yesterday someone wanted to chop off five characters from the front of a string with a regular expression.
@sbi Don't you wish C++ had one... `#define explode(args...) do {int * q = 0; *q = 0; } while (0)
 
They probably saw XCKD #208.
 
sbi
11:04 AM
@KerrekSB Huh?
 
@sbi That code usually "explodes" your program with a segfault.
Or it gets your girlfriend pregnant.
Which might be a good thing if you have balls of steel.
 
@MartinhoFernandes Yeah. And you can safely use it in loops and conditionals.
 
That too.
It's good that it works in ifs because you might want to explode the program only at times.
 
Hm, I was trying to add something meaningful to this attempt to read a password from the console. Apparently getpass() should not be used, but I don't know a useful alternative, short of handcoding something.
@MartinhoFernandes Definitely! Like when you're writing psminesweeper.
 
@KerrekSB I think the usual technique is to silence console output and read normally.
I don't know how/if you can do that portably.
Oh, I see you mentioned that.
On another day, I'd completely rewrite that question so it was decent. But today I'm tired, and I've got work to do, and it's the last day before my holidays and I already have a Copy Editor badge.
The title sucks balls.
 
11:17 AM
@MartinhoFernandes I don't... but I'm trying out my new 10k powers :-) Just discovered that there's a cap on "revision" votes, which probably saves this day from falling into nonproductivity :-)
@MartinhoFernandes You, on the other hand, probably would hate to go on holidays knowing that there's a terribly presented question on SO...
 
Bah, I changed the title. That's all I'm doing for it.
I swear there's nothing nagging me at the back of my head.
 
@KerrekSB yes, that's almost as bad as when someone is wrong on the internet :)
 
sbi
@MartinhoFernandes LOL! (BTW, did you know this answer of mine?)
@MartinhoFernandes Why do you feel the need to assert that? :)
 
11:35 AM
Telling people about UB is always a joy because one can use the Nasal daemons reference :)
 
@MartinhoFernandes It looks like a stupid homework exercise
 
Calling it stupid is an understatement.
Ok, I usually diss Design Patterns because people usually get the wrong idea from it. But now I realized that some people can never come up with the simple patterns like Strategy on their own.
At least the guy who wrote this code couldn't.
 
Which code ?
 
On the other hand he knew about the "Switch on the strings everywhere, copy-paste the code for another case and change some stuff" pattern.
@kbok The one I'm refactoring.
 
If we follow the definition in wikipedia, copy-pasting is a design pattern.
 
11:46 AM
No it's not.
 
> In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.
 
I'm starting to resent Boost.Build and I've not even used it for one of my project yet.
 
> A design pattern in architecture and computer science is a formal way of documenting a solution to a design problem in a particular field of expertise.
Hmmm, my wikipedia seems different, somehow...
 
@LucDanton join the club
 
Hah, got it.
There's a specific article for CS design patterns.
 
11:47 AM
What.
Ah, Ok.
 
I like the non-specific Design pattern article better.
Besides having a better definition, it has this:
> The usefulness of speaking of patterns is to have a common terminology for discussing the situations designers already see over and over.
Which should be all over the GoF book.
 
I +1 on this
 
Wow, a decent regex question: stackoverflow.com/q/6872705/46642
Shows an attempt at something, and has a valid reason to require a regex.
And it says which flavor is being used.
 
Well well well, I get an RTTI failure when using -fvisibility=hidden yet what I assume is the looked-up type is marked with default visibility.
I suppose this assumption might as well be wrong.
 
12:05 PM
5
Q: Why does Microsoft charge a fortune for its developer tools?

Kyle CroninMicrosoft charges thousands of dollars for most versions of Visual Studio. Compare this with companies like Apple and Google and with organizations like GNU and Eclipse that give away developer tools for free, it makes me wonder where the difference lies. The rationale behind Apple and Google g...

Hah.
> If they gave it away we'd all accuse them of leveraging their cash wealth to drive the smaller players out of the market and expand the monopoly. – Affe 15 hours ago
 
> Have you actually compared the tools you listed with Visual Studio? There isn't a comparison. Visual Studio is orders of magnitude better than any of those. Visual Studio is, bar none, the best integrated development environment in existence. – John Kraft
He's right, it's quite stupid to compare Eclipse and VS2010.
 
I've never used VS2010
I guess I'll have to try it, is it "compiler agnostic"?
 
No, it uses the MS toolchain.
 
Meaning that I could change it a bit to compile with gcc-mingw for example?
 
Well, actually...
You could.
VS uses MSBuild for the build.
You just have to change the project files (which are actually MSBuild "scripts").
Don't ask me how.
But now you sparked my interest :)
 
12:14 PM
:P
 
@Josh doesn't make sense.. if you know the solution you should post it
 
@JohannesSchaublitb doesn't make sense.. if you know the solution you should post it
I think that was the point he was trying to make.
Anyway, lunch time.
 
@MartinhoFernandes Just make it run a program in the pre-build step, like opening a bash shell that would just run 'make', and in your first c++ file add a #ifdef MSVC #pragma fail #endif
this is quite dirty lol
 
@hexa That's ugly.
I bet you can do it more "correctly".
 
Most likely
 
12:16 PM
@MartinhoFernandes hmm, that's an interesting idea, actually
 
Might require some work, like creating custom MSBuild tasks.
Or maybe not. I never delved much into that.
 
MSBuild is amazingly upside-down and unintuitive, from what I've seen. When you poke around with it, it's hilariously obvious that it's really little more than an XML-ification of their old ad-hoc VS build system
but it's powerful enough
just oddly put together
in that for the most part, it ignores the actual hierarchical xml structure
 
@hexa Why would you want to do that.
 
@CatPlusPlus Why not?
 
GCC sucks. GCC-MinGW doubly so.
 
12:23 PM
One day you will need to write portable code and realize that GCC is what you can rely on
 
@CatPlusPlus Find me a compiler with comparable C++0x support!
 
No, standard is what you can rely on.
 
@hexa you mean the compiler which, by default, allows variable length arrays in C++? ;)
 
g++ is by far the slowest C++ compiler I've ever seen.
 
Yeah, that's real portable ;)
 
12:24 PM
Whatever.
 
Not to mention GNU extensions are the reason we can't have nice things.
 
@CatPlusPlus There are situations where you don't have the choice
 
When I need to write portable code, the first thing I do is get hold of multiple compilers to test on. GCC should certainly be one of them, but relying on just GCC is a horrific thought
 
There is no reason to use GCC on Windows.
 
oh the pedantry started
omg.
 
12:25 PM
Some time ago, MSVC build for Qt needed a professionnal license.
 
you guys are annoying
 
Unless the code is broken.
 
@jalf How long is the list of compilers that start in conformant mode by default and why should it matter?
 
@kbok The open-source edition built with MSVC even then AFAIR, you just needed to do it yourself.
 
@hexa well, it was a pretty arrogant and condescending thing to say. What did you expect? ;)
 
12:26 PM
what was?
 
@LucDanton it's pretty short. And it matters if you rely on any one compiler when trying to write portable code
 
I hope GCC dies in fire and Clang takes its place for good.
 
I could care less about gcc this and that. my point is gcc 4.x.x runs in every platform business care about so yeah, what?
 
@hexa implying that those who disagreed with you had no experience writing portable code
 
@jalf I wouldn't dream of using a compiler without knowing a handful of options related to warnings and conformance mode.
 
12:27 PM
@CatPlusPlus I don't care if GCC dies, but I can't wait for Clang to become a viable alternative in every way (including C++0x support)
@hexa Moving the goalposts, eh? Now your argument went from "portable code", to "runs on the platforms I care about" ;)
 
Also the expression is "couldn't care less".
 
And yes, we're pedants. Don't tell me that came as a surprise to you. :)
 
@jalf There is such a thing as moving the goalposts and such a thing as giving the details/context: 'portable' doesn't have to mean 'source-code level portable'.
 
@jalf I might have expressed me wrong in the first place, I meant writing code that runs on every platform business care about
 
This is the C++ room after all.
 
12:32 PM
@LucDanton but the statement "One day you will need to write portable code and realize that GCC is what you can rely on" doesn't seem to me like "I just forgot to add some context about my situation", but rather "I am making an universal claim about the goodness of GCC, and about how everyone can rely on it"
as such, saying "oh, I meant I can rely on it for the things that I need" is definitely moving the goalposts
 
Tell me of another compiler that runs in the same number of system/architectures combinations as gcc
 
sbi
I'm not sure whether this is real, but the "you can barely say it now" is surely funny. :)
2
@hexa Why would you want to know that?
 
For the sake of my argument :P
 
@hexa I can't think of any. Is it relevant? Something that runs on GCC + other compilers will always be at least as portable as something that only runs on GCC
 
@jalf But that rests heavily on the working definition of 'portable' :/ If it's not the same definition, then you're interpretation is not what hexa wanted to convey. I'm not saying you shouldn't make the interpretation and/or argue against the original statement using that interpretation, but denouncing it that way poisons the discussion for no good reason.
 
12:39 PM
@LucDanton Perhaps. But I'd argue that implying that "you don't know anything about portability. If you did, you would know you can rely on GCC" is pretty poisonous as well. Even if it was misinterpreted. ;)
 
What C++ compiler do you use?
 
but for what it's worth, I'm just being pedantic. No hard feelings or anything. :)
 
@jalf I don't know, I find 'portable' to be too vague without context such that I didn't feel the need to address the original statement.
 
@MartinhoFernandes lol
 
Cool, someone asking about TMP
 
12:50 PM
@jalf In the sense that someone asking about Hello, World! is asking about programming or did I miss a question?
 
@LucDanton no, that's probably not an entirely inaccurate description
6
Q: compile time loops

WhitAnglI would like to know if it is possible to have sort of compile time loops. For example, I have the following templated class: template<class C, int T=10, int B=10> class CountSketch { public: CountSketch() { hashfuncs[0] = &CountSketch<C>::hash<0>; ...

 
Loops, 'Hello, World!', what's the difference? :)
 
or rather, I guess it's like someone asking if it is possible to write out "Hello, World!" using programming
but people accidentally stumbling across TMP make SO much more interesting ;)
 
> just got carried away with the tags sorry, and no how to stop a user from navigating away from the site set... – PESHuk 3 mins ago
Wow, some people get carried away with the most mundane of things.
 
so anyway, back to debugging...
 
12:56 PM
Dammit, this edit review thing is annoying. I have to use backdoors to edit a post if someone made a suggestion.
 
Camel-case directory names. Yuck.
 
Guess who's back?
 
@EtiennedeMartel you?
 
@jalf You're good.
 
1:10 PM
I'm not sure how I can get an RTTI failure for a type that is a template instantiation. (No explicit instantiation going on here.)
 
Please close this:
-1
Q: Ideas for C++ Practical Jokes

AxonnSince we've got a topic for "Ideas for web development practical jokes", I've thought of sharing with you one for C++. Let me start by saying this: define TRUE FALSE //Happy debugging, suckers This may be evil though... ::- D.

 
@MartinhoFernandes Voted to close.
Well, that went down faaaast.
It's the Stack Overflow police!
Plus it's not even a good "joke".
TRUE and FALSE? Uppercase? Really?
 
Didn't even notice that.
Actually, I barely read the question.
Just "Close > not constructive", grab link, post here.
 
Yeah, the big bold text pretty much overshadowed everything.
I voted for "not a real question" because, well, it wasn't even a question.
 
The reason is pretty much irrelevant here.
 
1:19 PM
Today I discovered Ctrl-W + gf in vim and I don't know why I never looked it up earlier!
 
vim? Man, that's soooo 1990!
 
vim is awesome.
 
Real men wait for hours while their Visual Studio stops hanging.
And they cuss everytime they hit "Clean solution" by accident.
 
Real programmers use butterflies.
 
Not again.
 
1:21 PM
I'm not sure how I should go about installing MSVC on Linux.
 
You don't.
 
Ah, yeah, forgot about that.
 
I think this answer doesn't have enough votes:
33
A: Most effective way for float and double comparison

Andrew SteinBe extremely careful using any of the suggestions above. It all depends on context. I have spent a long time tracing a bugs in a system that presumed a=b if |a-b|<epsion. The underlying problems were: The implicit presumption in an algorithm that if a=b and b=c then a=c. Using the same ep...

 
I agree.
 
Ha. Java 7 managed to break loops.
http://www.lucidimagination.com/blog/2011/07/28/dont-use-java-7-for-anything/
5
 
1:29 PM
@Collecter Oops.
 
sbi
@jalf: Here's another Singleton lover for your collection. <sigh/>
 
@Collecter This is probably the most groundbreaking change in Java 7.
 
@MartinhoFernandes Litterally.
 
> These problems were detected only 5 days before the official Java 7 release, so Oracle had no time to fix those bugs
Oh how I love release dates.
Who cares about critical bugs.
 
Who uses loops anyway.
Just use recursion.
And hope no one decided to implement tail-call optimizations.
 
1:42 PM
@MartinhoFernandes Also, this answer was accepted despite several shortcomings.
 
> Bottom Line: Don’t use Java 7 for anything (unless maybe you know you don’t have any loops in your java code)
Loops are for chumps.
 
> Please note: Also Java 6 users are affected, if they use one of those JVM options, which are not enabled by default: -XX:+OptimizeStringConcat or -XX:+AggressiveOpts
Wait, what? Optimising string concats breaks loops?
 
How are Java 6 users affected?
Was this bug already there for a long time?
 
No idea.
 
I think they broke division one time in the past, though I can't remember details.
 
Eclipse every now and then simply crashes and closes for no reason in every platform i use it
 
That one was broken in PHP, too, IIRC.
 
@CatPlusPlus What? double d = 2.2250738585072012e-308;?
 
@hexa I have never had a problem with eclipse. what version are you running? 3.7?
 
Yeah, something like that;
 
1:50 PM
@Collecter Where do I see it? I keep getting the CDT version only
 
Dunno if that's the same one, too lazy to compare.
 
@Collecter Version: 3.5.2.R35x_v20100210-0800-9hEiFzmFst-TiEn9hNYgDWg1XN8ulH_JvCNGB
 
@CatPlusPlus Almost the same.
 
@Collecter But at home I am pretty sure I use a newer version and it still crashes randomly
 
Apparently in PHP, 2.2250738585072012e-308 converted to 2.2250738585072011e-308, and worked.
 
1:52 PM
@hexa Should be somewhere under Help -> about eclipse. No idea why it would be crashing on you.
 
JK
2:14 PM
@ManOfOneWay: Are you working?
 
sbi
2:26 PM
@ManofOneWay: Yeah, I'd be interested, too! :)
 
@sbi @JK Of course! Documenting code. Very exciting.
 
@ManofOneWay Doxygen? Or old fashioned comments?
 
neither have much to do with documentation
 
Who needs documentation.
 
lawyers
 
2:40 PM
@hexa It's more a description than anything on how the application is composed. Less UML-diagrams, more English and pictures =)
 
aw those are the worse
 
@ManofOneWay Pictures? Eh.
 
@EtiennedeMartel Yes, I'm showing which Views in a MVC pattern that corresponds to certain Controllers.
@EtiennedeMartel This documentation is to be read by a programmer that hasn't touch any Iphone Development. So it has to be descriptive
 
I don't understand this whole 'app fever'
why would I, for example, need an app to navigate IMDB?
wouldn't a mobile version of imdb page be enough?
same for facebook or twitter or much of the apps around
 
JK
@Documenting: The gods must be crazy!
 
2:48 PM
@JK Nöter?
 
JK
@ManOfOneWay hmm, well you get it...
Nja gjorde, nu blir det nog lite helg
 
hej hej
 
du är från brasilien, du ska inte kunna svenska
 
JK
@ManOfOneWay Time for vacation
 
@hexa people just like having a dedicated app IMO. I think they generally look nicer than mobile pages as well. Not mention if they can cache, I can view things offline on my itouch, because well, not everywhere has wifi.
 
2:49 PM
man, that was all the swedish I had in me
 
@hexa haha
 
JK
@hexa poco pocu
what is abs(INT_MIN)?
 
@hexa Aplicações do iPhone são sexy
 
@ManofOneWay :D
 
JK
Humour in posts?
OK or always a no-no=
?
 
2:53 PM
@ManofOneWay I used to work with some swedish people, the ones that make the DreamHack lan party. Do you know of it?
 
@hexa Yes, sure. I've never been on one though. Have you?
 
JK
@hexa You know Greykarn?
 
Dreamhack was fun to watch.
 
@JK No I don't know him, I used to work with G3X
@ManofOneWay Never! :(
 
JK
I'm out, bless!
 
2:55 PM
later
 
@JK puss
 
@JohannesSchaublitb hey baby
 
ah yay, just spent the last hour or so debugging a misplaced )
btw, @JohannesSchaublitb or anyone else, is std::aligned_storage<...>::value allowed to alias everything the way char arrays are? Or do you need to mess around with a union of that and a char array in order to safely store objects into it?
 
3:06 PM
if you use another pointer and write with it, you destroyed any object therein
so aliasing will be satisfied
 
guys...
 
@JohannesSchaublitb +15 Accepted
 
if float and int are same aligned and sized on a particular platform, you can say float a; int *p = (int*)&a; *p = 10; cout << *p; in the current spec and it will work without UB. But if you later access a, you do an aliasing violation
 
ah ok. That's much nicer than I'd expected.
 
@jalf assuming std::aligned_storage<...>::type arena;, you can do T* p = new (&arena) T(...); with no issues. It's not always convenient to store both the arena and the correctly typed pointer I suppose.
 
3:09 PM
although I assume for non-POD types, I'd have to explicitly destroy one object before creating another one in the same location, but otherwise, it'd still work?
@LucDanton yeah, I don't have a way to store the typed pointer, unfortunately
 
you don't have to, if the program doesn't depend on the side effects the destructor does. i.e if the destructor has just an empty body, the class is a nonPOD but you don't need to invoke the dtor before creating a new object at its location
but if it's an automatic object as above, you need to have an object of the declared type stored in its memory, before the implicit dtor call happens, if the dtor is non-trivial (which includes dtors with empty bodies)
 
Wee, VVVVVV completed.
 
Also using a union would not make it correct, it would make it reliable.
 
@JohannesSchaublitb yeah of course
@JohannesSchaublitb hmm, interesting. Not that I have any plans of bypassing destructor, but interesting that it's legal to do so in those cases
 
@JohannesSchaublitb I didn't know that, that is very useful.
 
3:12 PM
@JohannesSchaublitb Seems dangerous to rely on types being the same size.
 
Hey, I was reading that!
 
hope you read it :)
i shall not insert long quotes of the spec into the chat
BTW 3.8p4!
@Xaade seems dangerous to me too
 
which spec is that btw? the 0x draft?
 
0x
but it was the same for 03
open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1116 would make my int/float example of above UB
which is why i said "in the current spec its allowed"
 
So, what's the consensus then? std::aligned_storage<...>::type arena; and only ever dereference (T*)&arena, including not using references to arena?
 
3:16 PM
but 1116 didn't make it into c++0x anyway
 
Hmm.... I miss "shall". Things are more confusing without it
I ended up with a problem determining the way to deduce phrase tense and realized it was because the will was in present tense. American English, no longer uses "shall" because it sounds haughty.
 
you shall not anymore access the stored value by the type of "arena", if its type is not (unsigned) char or an array of it, I would imagine. but I did not look up the definition of aligned_storage. I only speak by the aliasing rule!
 
I will not do that. I shall never do that.
 
@LucDanton but you can access the stored value of "arena" by its type, if you later do not anymore access it by type "T" anymore. so you can of course have a sequence of writes by T and the type of arena, but reads and writes by either type cannot interleave
 
The spec (for the nested type btw, aligned_storage itself is trait) mentions only that it is a POD.
 
3:20 PM
i think then the matter is what follows from the aliasing rule
 
@JohannesSchaublitb Thanks for the details. It always bugged me that the Standard added that really convenient trait and that I didn't know how to use it in a conformant manner.
 
so, while we're at it, supposing 1116 makes it into the language next time, what would be a correct workaround?
 
Small object optimize all the things!
 
Yeah in fact I'm going to write small_object<Base, T> right now.
 
3:23 PM
heh
 
not doing the float / int dance I suspect. get the memory by aligned_storage and hope for them to define " obtains storage for an object of a particular type A " to exclude the aligned_storage storage from being "obtained storage of a particular type A".
 
@JohannesSchaublitb Parse failure.
 
wouldn't the union thing work though? Create a union of aligned_storage and a char array, so that the array gets the alignment of the former. Then you can always refer to the array, and never need to reference the aligned_storage at all.
 
i think that would work
 
3:25 PM
I don't remember accessing the 'wrong' union member ever being correct (even though it's supported by implementations).
 
@sbi To paraphrase Keanu Reeves: Woa.
 
@sbi :D
 
So only use it to get the union size/alignment right?
 
but you wouldn't be. You only refer to the array member, never the aligned_storage one
@LucDanton yeah, exactly
 
0
Q: Compilation error with inheritance of templates accessed through pointer of pointers

FranckSpikeTemplate compilation error using pointer of pointer: (What causes the code not to compile ??) template <int DIM> class Interface { }; template <int DIM> class Implementation : public Interface<DIM> { }; template <int DIM> class Modifier { public: void modify(const Inte...

Did they really say "Visual Studio 1988" there?
 
3:27 PM
Well, I can still write my small_object and then switch to a union implementation if and when GCC supports unrestricted unions! I get my cake and implement it, too!
2
 
@CatPlusPlus jaw drop
 
@sbi Found that last night. It was great.
 
@sbi i first thought the formular defines a pure virtual function -.-
 
@CatPlusPlus Woa again.
 
@CatPlusPlus impressive
 
3:32 PM
0
Q: Compute the CRC32 table at compile-time

FredOverflowThe reference implementation of CRC32 computes a lookup table at runtime: /* Table of CRCs of all 8-bit messages. */ unsigned long crc_table[256]; /* Flag: has the table been computed? Initially false. */ int crc_table_computed = 0; /* Make the table for a fast CRC. */ void make_crc_table(void...

 
@FredOverflow i wonder whether it allows constexpr and c++0x
 
Does any compiler support constexpr yet?
 
gcc does and clang waits for certain spec issues to be resolved
 
btw, anyone know if there are any news from the standardization process?
been pretty quiet since FDIS
 
Last night I dreamed about meeting Bjarne. I asked him if he could do me a favor and cast my beloved "The Design and Evolution of C++" book from 'unsigned' to 'signed'... :)
4
Can't remember if he did it, though...
 
3:39 PM
lol
 
@FredOverflow array<> {value1, value2, value3 ...
 
There's always some smartass that shows up with the hardcoded solution.
2
 
	Animal
	  |
	Mammal
         / \
TwoLegged - FourLegged
    /           \
   Human      Lion

I have this class hierarchy, each class defined in it's own header.  Now when I include both
Human.h and Lion.h in the same place, I get a Mammal redefinition error.
This because Mammal.h is included in both TwoLegged and OneLegged classes.

I'm not sure how I could resolve this cyclic dependency in headers, as I cannot change the class hierarchy. (not for me)
 
3:52 PM
@Xaade How do you compute the values?
 
anyone can help me?
 
@FredOverflow I'm almost there. I just don't know how to build the array. Help?
 
there's still smart children around.
 
I have compute<T>::value that gives the value of each position.
 
@MartinhoFernandes see my crude solution:
0
A: Compute the CRC32 table at compile-time

FredOverflowFirst, I need to convert the core loop for (k = 0; k < 8; k++) { if (c & 1) { c = 0xedb88320L ^ (c >> 1); } else { c = c >> 1; } } into a meta-function: template <unsigned c, int k = 8> struct f : f<((c & 1) ? 0xedb88320 : 0) ^ (c &g...

But I'm sure there's a better way.
 
3:58 PM
Cheater!
 

« first day (286 days earlier)      last day (4660 days later) »