« first day (385 days earlier)      last day (4565 days later) » 

1:00 PM
or to make the FooClass a template
and have a make_foo function that deduces the type
 
Access violation writing location 0xabababaf.
It's a dog!
 
Coming from the oh so dynamic ObjC, C++ can make you feel utterly stupid despite having done pretty advanced stuff in other langs. :(
 
@Regexident - pretty much. I'd favour initialiser lists over this->x = x for the constructor
 
init lists. okay, noted. :)
 
and I'm surprised you want to pass BarClass by value not by reference (or pointer)
with initialiser lists you can make functor const if you don't plan on letting it change which means the compiler will catch one more possible mistake for you if nothing else
 
1:06 PM
both absolutely valid points.
 
Goin shoppin, like a boss.
 
@awoodland: So I'd end up with something like this? pastie.org/private/hyfj9ojqdddbci6yurj6ra
 
@Regexident Different computer languages are different.
 
@Regexident - I'd make line 3: const std::function<void (BarClass &bar)> functor; unless you have a reason not to, but other than that yes
 
@awoodland: done, thanks a lot!
 
1:15 PM
Why is the functor protected? Is FooClass a base class?
 
(I was having an internal debate about the merits of struct defaultFooFunctor being public too)
 
@FredOverflow: (re lang diffs) Very true. And that's pretty much the reason why I'm right now working in C++. To get a new view on things, from a different perspective, then my faimiliar duck-typing one.
@FredOverflow, @awoodland: Not yet 100% sure about that (base class), but most likely not (that's why I'm accepting a functor anyway, to not have to subclass it for different behaviour). Hence will probbaly make defaultFooFunctor private as well.
@FredOverflow, @awoodland: thanks, you guys are great!
 
(the argument for keeping defaultFooFunctor public is if it might be useful to derive from it later elsewhere)
 
anyone using clang on os x ?
 
nope, it's just going to be a nop anyway.
 
1:21 PM
@wilhelmtell - I guess silence means no :)
 
for some reason it seems to be using /usr/include/c++/4.2.1 for its standard library. it doesn't look right to me. doesn't it have its own library?
 
@wilhelmtell: I am right now, but new to C++, so probably not much of a help anyway ^^
 
IIRC clang can use one of two C++ library implementations
 
@awoodland: To give a little more insight: FooClass is actually an XML Parser for parsing the Wiki Dumps. It produces Article objects and passes them into the functor. I'm using the functor (or should I rather use a lambda?) to allow an instance of—say—BazClass to "subscribe/respond" to the parsed articles as they come out of the dump.
 
functor sounds quite reasonable there if it's sizeable - my current rule of thumb is basically how substantial the operator() is - if it's just making std::for_each look neat then lambda is probably fine, if it's bigger then name it and make it a functor
Is there a concise (online) table of what in the std::/boost:: namespace was added (and deprecated) where and when? (i.e. C++98/03/TR1/C++11/Boost 1.x.y)?
 
1:29 PM
@awoodland: boost::function should accept any of functors, function pointers and lambdas anyway, if I'm not mistaken (quick research in the meanwhile), right?
 
@Regexident right, as long as the signature matches
 
neat
 
@Regexident - it's an example of: artima.com/cppsource/type_erasure.html
 
Java gave type erasure quite a bad name, didn't it :)
 
1:39 PM
@FredOverflow - you mean the way all generics in Java basically become Object at runtime anyway?
 
yeah
1
A: How can i make a templated constructor allowing all of l-value ref, r-value ref and initializer_list?

FredOverflowThe preferred idiom is to pass by value and then manually move inside the member initializer list: struct my_class { my_class(std::vector<double> x, std::vector<double> y) : m_x(std::move(x)), m_y(std::move(y)) { } std::vector<double> m_x; std::vector<d...

no love? :(
 
1:54 PM
Please allow me one last stupid question... :P
This compile error, makes sense to me, but what do I have to do instead? pastie.org/private/i75g3rhtmxxvhprp3mzqq
 
We shall allow it!
 
@FredOverflow, yay!
 
Is DefaultHandler a data member or a method?
Line 6 looks like a static member, line 11 looks like a method.
 
A function object as a member variable apparently.
And he's trying to provide a definition as if it were a method.
 
But look at line 11.
C++ has no properties, maybe that's what he wants? :)
 
1:57 PM
Line 11 is empty.
 
void WikiParser::DefaultHandler(WikiArticle &article) {   // line 11
 
Well, what I basically want is to be able to provide it as a default value for this:
 
Are you toying with me because I'm sleep deprived?
 
WikiParser(QString xmlFilePath, boost::function<void (WikiArticle &article)> handler = WikiParser::DefaultHandler) : xmlFilePath(xmlFilePath), handler(handler) {};
(the class's constructor)
 
You cannot name a method the same as a data member.
 
1:59 PM
I think he's confused and thinks that std::function is a syntax that can be used for declaring member functions.
 
Again, in line 6 the compiler sees a static data member, and in line 11 it sees a method definition with the same name. It simply doesn't make sense.
 
@StackedCrooked, no ;) (but I'm confused either way)
 
Oh. Well change line 6 to this then:
static void DefaultHandler(WikiArticle &article);
 
@FredOverflow: okay, this just confirms it, I need more coffee. This was plain stupid. facepalm
enough from me now… thanks a bunch, guys!
 
@Regexident By parsing the WikiArticle, do you mutate it?
 
2:04 PM
btw std::function can exist without a function bound to it
 
nope, at least not after it gets passed to the function
 
so if you want to have a null default
 
Then the signature should be:
static void DefaultHandler(const WikiArticle& article);
 
you could just not set one and check before calling
 
In computer science, const-correctness is the form of program correctness that deals with the proper declaration of objects as mutable or immutable. The term is mostly used in a C or C++ context, and takes its name from the const keyword in those languages. The idea of const-ness does not imply that the variable as it is stored in the computer's memory is unwriteable. Rather, const-ness is a compile-time construct that indicates what a programmer should do, not necessarily what they can do. Note however, that in the case of predefined data (such as const char * string literals), C const i...
 
sbi
2:05 PM
GotW #100: Compilation Firewalls http://wp.me/peb5Y-ew
 
@awoodland, yeah, I don't want a null, though (rather make it print by default, than confuse user be doing nothing) :P
 
I would expect an unbound function object to crash when trying to call it...
 
@sbi - I wish that blog had code markup support in the comments
 
27
Q: Sell me on using const correctness

Jason BakerSo why exactly is it that it's always recommended to use const as often as possible? It seems to me that using const can be more of a pain than a help in C++. But then again, I'm coming at this from the python perspective: if you don't want something to be changed, don't change it. So with th...

 
@FredOverflow: thanks for the link!
/me is off to find some of @awoodland/@FredOverflow/@StackedCroo answers to upvote furiously! :D
 
2:10 PM
5
Q: Are serial upvotes detected?

squillmanBased on a tweet from Jon Does the automated jerk detector also double as an automated nice-guy detector? I was under the impression it just blew out serial-downvotes. What all is caught by the system?

 
sbi
You'll find them here, here, and here.
 
@awoodland interesting
@sbi I'm so proud of my nice, round multiple of 1000 user id :)
 
sbi
30
Q: Shouldn't anonymous serial downvoters be banned from SO?

sbiThere was a discussion about unexplained anonymous serial down-voting in the C++ room this morning (starting here). The user affected by it explained it to me thus: It started on a particular Q, Wherein, I had a rub-in with a particular user over one of my answer. Immediately,within seconds,...

@FredOverflow Are you? but it's only a round number in the decimal system.
 
@sbi And I have ten fingers. Don't you? ;)
 
Serial upvoters should be engaged to counter the problem of serial downvoters.
 
sbi
2:19 PM
Jun 20 at 15:52, by Cat Plus Plus
> If we had e fingers on each hand, our numbering system would have been a lot more natural.
 
How about cereal downvoters?
 
sbi
@StackedCrooked Or the other way around? Seriously, both are abusing the voting system.
 
is there a way to get gccxml to show uninstantiated templates in its output? or another tool that does show them?
 
There won't be any uninstantiated templates if you write proper tests ;)
 
I wanted to parse standard library headers to chart implementation of features
 
2:26 PM
What does that have to do with the uninstantiated templates?
 
it occurred to me a "can I use std::X" with implementations X,Y & Z tool would be quite handy
so for example does libstdc++6-3.4 support std::function (a: no). does libstdc++6-4.4? a: yes
but in an automated way
in much the same way I have a "does this system call exist on this system" quick reference chart
 
nice
 
but the lack of uninstantiated templates in gccxml seems to be a show stopper
unless I write hundreds of tests by hand
and clang says "do not use the ast dumps for tools"
and swig doesn't do it in the XML output either
 
2:52 PM
I installed GCC 4.6.2 -- I think it has a new switch -fstack-usage that writes the stack usage of each function to a separate file.
That's pretty sweet.
 
3:16 PM
howdy
 
3:31 PM
WOW
Any Fringe fans?
 
3:55 PM
@jalf I'm working on Mac and updating the CMake file to use gcc-4.6.1.
 
ah cool
 
4:11 PM
what is the default encoding scheme for Unicode in c++ under windows?
 
Can I link with a GCC 4.2 library from my GCC 4.6 code?
 
Windows uses UTF-16 internally, AFAIR.
wstring is not encoding-aware.
 
4:28 PM
@CatPlusPlus you're write , was my mistake that i had asked such thing. Anyways thanks
 
@jalf GCC 4.2 and Apple GCC don't like each other. I switched Linux now :D
 
heh
 
Just trying to find the quickest path to actually toying with the concept.
 
How does one use an ASTConsumer with clang to print more than just the name of a namespace in which a declaration lives?
 
4:55 PM
@StackedCrooked which concept?
 
I just mean trying out your code in my program.
The concept being STM I guess.
 
ah right
yeah, I'm not entirely sure how new a version of GCC you need. I've got some lambdas and autos in the code, iirc, so probably 4.5 or newer
should be pretty easy to backport to C++03, but I just haven't done it
 
I'm a bit late to the party concerning C++11.
But latest Ubuntu comes with GCC 4.6.1 out of the box.
 
Is that the current GCC version?
 
4.6.2 is most recent.
 
5:05 PM
@user411102 utf-16, except in console windows which are restricted to ucs-2 (a subset of utf-16)
 
@StackedCrooked I've mainly developed my library on Windows, so the only C++11 features I use are the ones supported by VS2010
 
I see. No prob, I'll work it out.
 
@sbi Hah, some idiot had downvoted my comment. A better being had upvoted it. I had to add an upvote to cancel the silly downvote, otherwise people could get quite the wrong impression.
 
> Improved experimental support for the upcoming C++0x ISO C++ standard, including support for constexpr (thanks to Gabriel Dos Reis and Jason Merrill), nullptr (thanks to Magnus Fromreide), noexcept, unrestricted unions, range-based for loops (thanks to Rodrigo Rivas Costa), opaque enum declarations (thanks also to Rodrigo), implicitly deleted functions and implicit move constructors.
@StackedCrooked cool
@AlfPSteinbach Oh, can we finally downvote comments?
 
@FredOverflow On Herb's blog, at least.
 
5:11 PM
oh :)
 
I thought there was a 4.7?
 
@DeadMG not as a stable release
 
ah
 
stable is for sissies
 
haha
yeah
 
5:40 PM
hmm
why is friday RAII?
 
every day is RAII-day!
 
I assumed it was a play on the finally part of try/catch in Java
 
fRAIIday!
2
 
Als
oops an exception just zipped past me.
 
@FredOverflow It's Saturday, sorry.
 
Als
5:49 PM
Oh I saw a code on Friday that checked return value of new for null and it was not the nothrow version.
I had an immediate urge to throw up which I had to conspicuously resist because I was told my project manager wrote it when he was in a technical position earlier.
 
Als
I was talking alone
none of the peeps showed the enthusiasm about my rant.
@JohannesSchaublitb: You didn't either~
 
Als
Oh wait Am i banned or something that people cannot see me?
 
user457812
I had a dream about baby deer
 
6:02 PM
my colleague thought htat "X x = y;" default constructed x and then assigned to x
and told his colleague who sayd that this uses a constructor "no, it's =, so it's assignment!"
when I clarified and said that it is indeed a constructor use only, he was all in rage
 
Als
:P default constructed thats innovative why u need y there then :P
 
user457812
They were on my roof and watching me through a window, so I went out onto the deck to see them and they ran to the corner of the deck. One jumped over the railing and died after screaming, while the other kind of tried to but seemed to regret it so I caught it and pet it and it became my bestest friend.
 
user457812
Then Adam Sandler showed up in the dream and it turned into a nightmare.
 
Als
@JohannesSchaublitb: Rage? really! people really dont like to be pointed out with their mistakes...in these cases sins...
 
@JohannesSchaublitb that uses implicit initialization, right?
 
Als
6:05 PM
@nil: Are u a 15 yr old dreaming of deers?
 
user457812
Why would 15 year olds dream of deer?
 
Als
because your dream is weird
 
user457812
Yes, it is.
 
user457812
But I fail to see why you would think I'm 15.
 
Als
@user411102: that is copy initialization.
@nil: Are you?
 
6:06 PM
nil computes to 15 if you add 15
 
@Als but implicit one , right?
 
@Als Maybe he was on VS6?
 
user457812
I don't know, maybe check my profile and see that I'm not 15?
 
Als
@FredOverflow: Non..On Linux.
 
@JohannesSchaublitb Is y an X?
 
6:07 PM
is the size of begin - end the same as size of a vector?
 
@FredOverflow it may be and it may not be
 
@bamboon You mean end() - begin().
 
@FredOverflow yeap
 
Als
@user411102: What do you mean by implicit one? It is copy initialization, which can be restricted by using explicit
 
hai
 
6:08 PM
if y is an X there is a diff too
to X x(y);
 
@Als X x = y;<- implicit , X x(y); <- explicit i think
 
Als
@user411102: First is Copy Initialization second is called direct Initialization, Those are the names.
 
make -j8 is not a good idea on VBox, it just freezes everything
I even have 8 (hyper-threaded) cores assigned to the machine.
So it technically could make use of them.
 
Tell me , does this app look useable:
 
@Als you're right , my mistake
 
one thing to keep in mind: an empty app is always usable
 
@JohannesSchaublitb uploading takes time.
 
@IntermediateHacker i don't understand what you mean?
because you can always use it as a base for a non-empty app
 
@JohannesSchaublitb Oh sorry, I thought u were referring to my delay in uploading the screenshot, hence an "empty app" i.e no screenshot.
 
6:14 PM
@JohannesSchaublitb i have often made the error of thinking people would be interested in objective truth. they aren't, because most people are more social beasts than scientists. so the who appears to be right or who gets his/her will, is much more important than truth.
 
Als
@user411102: No worries
 
anyway, is it useable, or should I work more on the interface?
 
@AlfPSteinbach I disagree. I believe that our reality is being watched at by metaphysical creatures
so that if you are really right you will be in fame in their world
 
Als
fuck, some gibberish pedantic talk.
@IntermediateHacker: The wait dialog box looks ugly IMHO.
 
@JohannesSchaublitb the main error is not notice when the other party really starts interpreting objective arguments as authority/social challenges. of course it is there from the start also. but IME it tends to escalate exponentially as the other party realizes objective error. i think maybe that's what you experienced. it is difficult to see because it is so unthinkable, so utterly dumb, but it's what often happens
 
user457812
6:17 PM
I've noticed the people starting Android rooms exhibit this a lot.
 
concurrency is like quantum physics
 
Als
What is dynamic Inheritance in C++?
 
there is no such thing
 
Als
Pardon me if it sounds stupid I was just exposed to it.
0
Q: dynamic inheritance in C++

spanitepkm81In interview I faced the question about dynamic inheritance, but i had never used the dynamic inheritance in C++,so I was not able to answer properly. I want to how can we implement dynamic inheritance in C++ and what is the practical use of dynamic inheritance in C++ language?

 
user457812
What
 
6:21 PM
@Als already 2 answers :-)
 
Als
lulz
You tricked me!
 
user457812
@AlfPSteinbach Both downvoted in rapid succession, it seems
 
@nil u mean upvoted?
 
user457812
I upvoted them after they were downvoted
 
Als
@AlfPSteinbach: I was thinking of putting an comment and geez you guys!
@AlfPSteinbach and @DeadMG got free rep :P
 
user457812
6:25 PM
It might be incorrect to say there's no such thing as "dynamic inheritance," though I'll be damned if I've ever actually heard anyone use that to describe a language. For safety's sake, it might be best to just say it doesn't exist in the context of C++.
 
I was downvoted too
technically, you could dynamically inherit in any language which supports run-time code generation
but C++ is not one of those
 
there is an active downvoter
 
user457812
He, or she, is probably among us this very moment
 
no, I think it's just the OP who doesn't like the answers. people are like that. they don't like answers that they can imagine put them in a bad light.
 
user457812
6:29 PM
What, you didn't answer my question and affirm my belief in something? How dare you! My sense of entitlement rages!
 
Als
@AlfPSteinbach: Op must be infuriated he got done by a non-question in an intreview
so s/he hopes it is an question atleast
hence the downvotes I think
@AlfPSteinbach, @DeadMG: Have you countered all negativity :P
 
lol
 
Als
wow if i knew there were 5 upvotes to be cashed in, I would have added the NO myself instead of giving you guys a hint of it :P
 
6:59 PM
0
Q: How to refactor an API

limyrethHow do you deal with APIs that should be refactored, while not breaking the clients that use the API? One possible solution I came across: recording refactors to the API, providing the recording to clients of the API which can then apply the refactors to their code: https://netfiles.uiuc.edu/dig...

Lol @ the pattern guy.
 
@CatPlusPlus I have always wondered about that
 
All my cpp files that directly or indirectly include "boost/thread.hpp" fail to compile.
 
@StackedCrooked Are you on mingw ?
 
3rdParty/Boost/boost/thread/detail/thread.hpp: In function ‘boost::thread&& boost::move(boost::thread&&)’:
3rdParty/Boost/boost/thread/detail/thread.hpp:349:16: error: invalid initialization of reference of type ‘boost::thread&&’ from expression of type ‘boost::thread’
Nope I'm on linux.
 
uh
something wrong with std::move?
 
7:09 PM
What Boost version, and what compiler version?
 
But I'm using GCC 4.2 with C++0x on.
 
Upgrade.
 
gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
 
Well, it's not 4.2.
 
Boost 1.42.
 
7:10 PM
Oh. Upgrade.
 
@CatPlusPlus Oops, sorry bout that.
Probably I should.
 
Als
Apparantly, @CatPlusPlus has a cookie and She won't share it.
 
Or use std::thread...
 
7:24 PM
I need to stop answering questions about IDEs.
Each answer generates 1000 more questions.
 
I hate my university
 
Everyone does.
 
true true
 
8:20 PM
I don't hate your university
 
8:36 PM
I feel indifferent about your university. But I do find the occasional rants entertaining.
Anyone here that often uses Linux (Ubuntu)? Do you also have the annoying focus-stealing behavior or am I alone bothered by this?
I'm typing, and suddenly a popup from another application appears, causing me to type in a different text box suddenly.
Stuff like this can drive one crazy if repeated enough.
 
GUI apps are stupid like that.
 
I don't really have this on Windows or Mac. It's typical for Linux.
Another nasty thing is that clicking the scroll wheel is a paste operation.
I remember being freaked out because unrelated text was starting to appear in my source code at random times. Often I noted not on the moment self, but later.
 
X is stupid like that. And many other ways.
 
Then there is the triangle issue. We all know that in a folder view V means sort descending, and vice versa. On Linux (Gnome/Nautilus) it's the opposite.
Hey I got a downvote.
0
A: Learning C++ on Linux or Windows?

StackedCrookedI recommend that you stick with Windows for a while until you gain some familiarity with the language. Then you can switch to Linux if you like. I say this because on Windows you can use Visual Studio (the Express Edition can be downloaded for free). Its user friendliness will ease some of the pa...

Must have been a *nix zealot.
I have a deadlock in my Tetris code and it only occurs on non-Windows systems when using Boost version > 1.42.
I saw that somebody posted this as a bug. But I'm using 1.46 now and still having the deadlock.
Good opportunity to find out if Helgrind is any good.
 
sbi
8:57 PM
I just learned that my father was evacuated today. :(
 
From his house?
 
What does that mean, evacuated?
 
sbi
Yeah.
He lives in the El Golfo region of El Hierro (the westernmost of the Canaries.)
 
Is there a flood or something?
 
Oh, I thought there were health concerns or something.
 
sbi
8:58 PM
They have had tens of thousands of earthquakes since July (shortly after I left), and volcanic activity.
 
So nothing personally life-threatening?
 
sbi
 
@sbi Wow
 
sbi
Apparently this is a new vent which appeared only tonight.
@FredOverflow Earthquake/volcanic forecasts make weather forecasts seem hard science, rather than weak statistics.
Apparently they had a 4.4. quake last night (you start to feel them beginning around 4.0), which rattled the house he lives in.
The whole gulf area lives beneath a 1000m rock wall, and he said they heard rocks tumbling down that wal for a long time after the quake.
Today they were evacuated.
I'm not even sure the whole gulf was evacuated, but if, we're probably talking several thousand people here.
My father stays with friends now.
 
9:04 PM
Are earthquakes and volcanoes weather?
 
sbi
@CatPlusPlus I'm not sure how I am to respond to this.
 
Weather is the state of the atmosphere, to the degree that it is hot or cold, wet or dry, calm or stormy, clear or cloudy. Most weather phenomena occur in the troposphere, just below the stratosphere. Weather refers, generally, to day-to-day temperature and precipitation activity, whereas climate is the term for the average atmospheric conditions over longer periods of time. When used without qualification, "weather" is understood to be the weather of Earth. Weather is driven by density (temperature and moisture) differences between one place and another. These differences can occ...
"Weather is the state of the atmosphere" - earthquakes and volcanoes are most certainly not.
 
8 mins ago, by sbi
@FredOverflow Earthquake/volcanic forecasts make weather forecasts seem hard science, rather than weak statistics.
Well, I might be misreading something.
Nevermind.
 
The weather forecast can only predict max 5 days ahead. I wonder if this boundary could be broken by better weather models and technology. Or is the weather inherently unpredictable.
 
Well, weather is a highly chaotic system. We can get better and better predictions with better and better instruments but they come along slowly and will never be perfect anyways.
 
sbi
9:16 PM
@StackedCrooked Actually that isn't a border. Rather, the probability of the forecast being right is going down constantly the longer you look into the future. After five days, it's at ~55%, which is very little over guessing.
 
Yeah. I could then rephrase the question as follows: is the steepness of decline something that we can reduce with more effective science and technology.
 
sbi
@StackedCrooked Weather forecasts generally become better with increasing complexity of the underlying model, but that requires unobtainable computing power. (Besides knowing the many influencing factors, of course.)
 
Does quantum have something to do with it? From the little I have read on the topic I remember that one of the consequences of the theory is that the future is not deterministically decided by action and reaction. There is a randomness factor. I guess this randomness "stacks" over time. Thus the weather can't be predicted because it is actually unpredictable.
 
sbi
@StackedCrooked We are very far from the level of prediction where quantum effects are important. In fact, we're still far from the proverbial butterfly causing a hurricane on the other side of the planet by flapping its wings.
A vent off the cost of El Hierro, published two days ago.
Wow. This one is even more impressive. The brown underneath the clouds is the island, the strange green color in the sea around it is, apparently, what those submarine eruptions spoil the sea with.
 
sbi
9:40 PM
Steaming hot (literally) pyroclastic material swimming in the sea off the coast of El Hierro: earthquake-report.com/wp-content/uploads/2011/09/…
 
10:10 PM
evening
 
10:44 PM
the planet is wonderful
i always think about that one music title of Herbert Grönemeyer where at the end he sings about earth
 

« first day (385 days earlier)      last day (4565 days later) »