« first day (774 days earlier)      last day (4188 days later) » 

sbi
10:02 AM
There's still a void main() in there, @sehe. :(
 
@sbi "switching over types?" What's that mean?
 
sbi
@Mysticial switch(obj.type_id) { case employee_id : handle_employee(obj)...
 
ah
 
@sbi It depends how big the switch is. A virtual dispatch is certain to be slower than a two-way if.
 
Okay, a fully virtualized dispatch is two sequential indirections. (indirect jumps)
 
10:04 AM
Correctly predicted branches take literally no time. There is literally nothing that is faster.
 
A switch over types will depend on the how the switch is implemented.
 
@Potatoswatter not true :) Correctly predicted branches are cheap, not free
 
sbi
@Potatoswatter With caching and pipelined processors, this might be.
 
If it's done as a binary-branching tree, then you have potentially log(n) branches.
If it's done as a table-lookup indexed by the type id, then it depends on how sparse the type ids are laid out.
 
sbi
Anyway, I'm off to go to work. It's already past 11am, so I have to hurry to arrive in time for lunch. :-/
 
10:05 AM
The compiler will probably implement log(n) branches until a lookup table would be faster, and the LUT is comparable to a vtable.
 
> The logic of the best is so pernicious because it’s poised to monopolize — an emphasis on the consumption of material goods can easily translate into a life of generalized consumption. A whole language can start to develop around not just the consumption of goods, but the consumption of experience: “We did Prague.” “We did Barcelona.”
Heh, I'm glad to hear I'm not the only one who is annoyed to hear that
 
Btw, branch prediction is a lot more advanced than branch target prediction.
The two indirections in a virtualized call involve branch target predictions.
 
@Mysticial They're equally advanced… they're both just caches. But branch prediction works more reliably.
 
A branching switch statement is normal branch prediction.
 
@Mysticial two?
 
10:08 AM
@Potatoswatter Branch prediction has some pretty advanced algorithms. Branch target prediction, from what I've heard, always predicts the last jump it took.
Assuming that's true, if you have virtual calls that alternate between two different sub-types, you'll get a branch target miss every single time.
 
@Potatoswatter Look up vtable, then look up function address in vtable. That's two indirections
 
Better sort your polymorphic collections by type then ?
 
@kbok Ideally, yes. And once you do that, you can do better than virtual dispatch anyway (no point in going through the vtable every time. You know something the compiler doesn't after all)
 
@Mysticial Branch prediction assigns a number 0..3 to each branch. More advanced algos might exist for JIT type machines but the microprocessor is constrained by resources.
@jalf Those are memory indirections, which both shadow a single target prediction (indirect branch).
 
@Potatoswatter The branch predictor we implemented on second year at university did that. The ones made by Intel and AMD are a wee bit more complicated. ;)
 
10:11 AM
@Potatoswatter Oh no... they are much more complicated than that already. If you take the example from that branch predictor question and reduce the data size to 1K or so, then it will be correctly predicted regardless of whether it's sorted. In other words, the CPU has a large history buffer.
 
@jalf But if you're not the author of the used classes, what can you do ?
 
I was quite surprised too when I was playing around with it. They significantly increased the branch history buffer in Sandy Bridge.
 
@kbok if you're not the author of the user classes, the entire discussion of the efficiency of their implementation is irrelevant. ;)
Although even then, you could work around it. Take the address of the function you get from a single virtual dispatch, and then call that pointer directly (bypassing the vtable) on all the subsequent calls?
@Mysticial real-world branch predictors are insanely complicated monsters...
I liked the two-bit one we implemented at uni though. At least I was able to understand it ;)
 
&myObj->virtual_func() ?
 
@jalf I've studied slightly more complicated ones that track history of itself and nearby branches (aka correlating predictors).
Then there are the neurological predictors which are well beyond me...
 
10:18 AM
Are they actually implemented in processors ?
 
Huh. Guess it's been a while since I went to school :(
 
@kbok where else would they be implemented?
 
@jalf They could not be implemented yet
 
Oh, I see
 
@kbok The most advanced of the neurological predictors are still only in academia. But all the ones that I've studied are implemented in current processors.
 
10:19 AM
@jalf JITs have branch prediction too, and similar algos would be used for PGO.
@Mysticial you have the advantage of being at UIUC… but Itanium only sort-of counts as a real processor :)
 
lol, there's a mxsdk directory in the source root, and also a mx-sdk. Which one should I pick ?
 
Although I haven't studied prefetching algorithms, I have a feeling that those are even more complicated than branch predictors.
 
12 hours ago, by R. Martinho Fernandes
I am going to implement the dashy one.
 
Branch prediction is only a yes or a no. Prefetching requires an address.
 
I'm glad to be on this side of the fence.
 
Xeo
10:23 AM
@LucDanton Aw, why not?
 
@sbi I have no idea what that refers to
Yeah. That's simple. Mainly because it doesn't do what the OP asked. This just does a union of two maps. The OP specifically deals with maps that map the same key type to distinct value types. The end result can never be the original map type. I.e. 'merge'(map<K,V1>, map<K,V2>) -> map<K, tuple<optional<V1>, optional<V2>). (My answer even allows for inhomogenous (but comparable) key types, and allows the caller to decide how to represent the valuetype.) — sehe 2 mins ago
^ someone thought he'd misread a 14 month old question and provide a 'simple' answer /cc @KerrekSB :)
 
@R.MartinhoFernandes oh god why
 
> A closely related but distinct character set is ISO-8859-1 (distinguished by a dash after "ISO").
 
It's not a dash, it's a minus sign.. mx without the sdk
 
10:27 AM
@kbok Ah. Read further and you will find the full story. It's even funnier.
Is "funnier" the right word here?
 
Xeo
std::function, Y U NO ::arity like boost::function?!
 
YES
Resounding
@sehe - yes, we can vote to get rid of this one (to keep SO clean) — kfmfe04 2 mins ago
^ anyone want to vote?
Wait a sec, why doesn't the OP delete?
 
Dupes stay as signposts.
 
Xeo
0
A: Constructor initilizer list for a class with multiple arrays (C++11 is ok, boost and std::vector are not)

Joachim PileborgBesides the answer from Nicol Bolas using template parameters to make the size compile-time configurable, you can also allocate memory on the heap: class FOO { public: // this constructor needs to size x = count and y = count * 4 FOO(int count) : x(new BAR[count]), y(new TAR[count]) ...

 
If a thread is joinable when destructing it then it will throw a system_error from its destructor. If you try to join a thread that is already joined then you also get an exception. I could use something like if (t.joinable()) t.join(); , but this doesn't seem thread-safe. What is the correct solution then?
 
Xeo
10:36 AM
Ouch, I would've thought someone like Joachim wouldn't fail to mention the Rule of Three.
 
@Xeo Slicing from N to M isn't very general.
 
Xeo
@LucDanton And I just remembered that your steps may not necessarily be +1
 
@StackedCrooked That is only problemantic if you are sharing std::thread objects. Not something I would worry about often.
 
@Xeo That's what I said!
 
10:39 AM
Btw, what do you think of the idea of writing a reinvention of std::vector on gist to offer to anyone that has a requirement of "not use std::vector"?
 
meh
 
Xeo
@R.MartinhoFernandes Why write one? Copy a standard implementation and put it in namespace not_std.
 
Oh freddled gruntbuggly,
Thy micturations are to me
As plurdled gabbleblotchits on a lurgid bee.
Groop I implore thee, my foonting turlingdromes
 
@Xeo That's what I meant by "write".
@Cheersandhth.-Alf Reminds me of Carroll for some reason.
 
@Xeo Is now a good time?
 
10:44 AM
@R.MartinhoFernandes Nonsense!
 
:)
Anyway, why did you write a poem about pissing?
Oh, it's a Vogon poem.
How the fuck did I miss that.
HOW?
 
@R.MartinhoFernandes unless autodeleted :)
 
Xeo
@Mysticial Yeah, right now is good.
 
k
gimme a sec
Don't dump the answer all at once though.
 
Xeo
I need to actually write it anyways.
I only have the skeleton still.
 
10:47 AM
Have something ready, or you'll get beaten.
 
Xeo
Heh
 
I hope I don't get too many downvotes for this...
 
@Mysticial you're not going to... right?
 
What are you guys plotting?
 
hi guys... can we do polymorphism for overloaded binary opearators ?
 
10:49 AM
I'm really afraid that everyone is gonna come down on me and close it as "too localized" and downvote it as being "too stupid".
 
@balasbellobas Does not work. Not without zillions of work, no.
 
@balasbellobas google multiple dispatch or multimethods
 
posted
find it in the questions list
 
that is seriously lame
 
10:52 AM
I think that was a bit too fast... oh well
 
thanks
 
6 years of C++, and I've never learned lambdas... I guess that's next on my to-do list. — Mysticial 13 secs ago
You are such a terrible liar.
 
@sehe, I'd appreciate, if you deleted that comment.
@sehe, I had no idea you were so against this. I'm sorry.
 
@Xeo you should explain what the int main { } part means.
:P
 
Xeo
Uhm... really?
 
10:57 AM
Seriously, you explained the semicolon...
 
Xeo
Oh, right. :D
@R.MartinhoFernandes Btw, int main(){ }
You forgot your pants parens.
 
I am not the one doing the explaining.
 
I'm afraid our configure script has Alzheimer's :(
 
Next up: How is "throw throw throw throw throw throw throw throw throw throw throw up;" valid Wide?
 
user1182183
remind me what Alzheimer again is
 
Xeo
11:00 AM
@R.MartinhoFernandes Didn't you guys make him fix that?
 
It's a brain disease commonly found in old people which affect memory capabilities
 
@GamErix that's how it all starts :P
 
user1182183
@TonyTheLion :P
 
@Xeo Yeah.
-1
Q: Array of template class object

PatoufI'd like to make an array of multiple template objects. The object : Foo< typename A, typename B, typename C > FooItem (Bar bar_, Bor bor_); Array of void* pointers ? Classical array ? Thanks !

Pure nonsense, right?
 
What do you guys think? This configure script sucks donkey dick right? Should I mention it takes 5 minutes to run?
The templates parameters aren't used. What the hell does this guy want?
inb4 counter-downvote
 
11:04 AM
Okay... now I'm starting to regret this...
 
user1182183
@Mysticial ?
 
I didn't realize that sehe was that against it.
I don't blame him at all. But rather, I should've been able to read him better.
 
@Mysticial Why do you think that? I think he doesn't give a crap.
 
@Mysticial What are you referring to?
 
11:07 AM
@kbok If he didn't give a crap he wouldn't have linked directly to the chat transcript.
6
Q: How is "int main(){(([](){})());}" valid C++?

MysticialI recently came across the following esoteric piece of code. int main(){(([](){})());} Reformat it as follows to make it more readable: int main(){ (([](){})()); // Um... what?!?! } But I can't get my head around how (([](){})()) is valid code. It doesn't look like function pointer...

 
@StackedCrooked So... there is carbon on Mars?
 
That got me ast least 3 downvotes. Assuming the first one was his.
 
@R.MartinhoFernandes Apparently.
 
Xeo
@Mysticial We can always just delete it. :P
Even if it was kinda staged, it would've been the same as if you asked and answered yourself.
And it is a valid question, there's no arguing against that.
 
Nah. I don't have enough questions to do that.
 
Xeo
11:10 AM
@sehe can't just say "no, you can't ask why int main(){(([](){})());} compiles"
 
Imma reddit it for repwhoring
 
@kbok Please don't.
 
fine
 
@Xeo He can if he got Mysticial under an NDA.
 
I don't want to risk a diplomatic incident :)
 
11:13 AM
Okay... I think the only way for this to be fair for @sehe, is to actually just delete it.
@Xeo, are you fine with it?
Or we can wait a bit longer
 
Xeo
@Mysticial Really, disregarding the kind-of staging, this is still a valid question, IMHO.
 
Isn't it just a good question and well answered?
 
it doesn't look like a valid question.
 
take that serious?
 
@billz Well, the comments spoil it badly.
 
Xeo
11:15 AM
And if you really want to disassociate yourself from the votes, well, flag it and ask for making it a community wiki.
@Abyx Why not?
 
lol @ topic
 
uhm... maybe it's valid, but I just don't like what-is-this-syntax-construct questions
 
@Xeo I'd probably go with full disassociation. As in, remove it from my account completely.
 
^ Why on Earth did Tim Post delete that? Answers the question. Contains highly relevant information. Jeez.
Maybe Tim Post never heard of a C++ interpreter.
 
Because it's a rant that does not answer anything?
 
11:21 AM
It answers the question?
 
Xeo
@Cheersandhth.-Alf How the hell does that answer the question?
 
"Now we're stuck with the current mess as alot of code relies on typeid() and decltype() for a variable coming out as the plain type"
That's the last sentence, following the explanation of the matter that the others just can point to the rules with no understanding.
 
There was not a lot of code relying on that decltype behaviour because decltype is new.
 
@R.MartinhoFernandes The author talks in present form, not past (preteritum)
 
@Cheersandhth.-Alf That post is almost two years old.
 
11:25 AM
@Xeo I don't :)
 
@sehe, I'm gonna give you the call. I take all the blame for not realizing how much you were against it. Do you want us to delete the question?
 
And the explanation of the matter seems to consist of mention of some C++ unicornpreter that does not know of lvalues and rvalues.
@Cheersandhth.-Alf And the question itself is almost two and half years old.
 
@Mysticial Nah it's okay this way. I'd just hate when this would have gone viral. I mean, SO gets subverted with 'reddit' material on occasion, I don't like it when it would be done... basically on purpose.
The question has merit. Flimsy, and largely crippled by the fact that google nor SO search will be able to index this syntax. But it's fine as a question
 
@R.MartinhoFernandes hm, mention of unicorns fails to convince me
 
@sehe So would it bother you if you wiped the comments linking here?
 
11:28 AM
I made my case. I won't try to hammer it home.
 
Xeo
Also, the reasoning is bogus. Since we have rvalue references, not every reference is an lvalue anymore - T&& foo(); is an xvalue, a form of rvalues.
 
@Mysticial Of course that would bother me. Apparently giving it a balanced start helps keeping the public 'honest' in the voting patterns. We could agree on reducing the amount of linkage. Lemme ssee
@Mysticial I agree to remove our mutual comments starting from your You kinda authorized me to post it down
(done)
 
@Xeo i think that reasoning is bogus. the current scheme is just an absurdly complicated way to try to keep track of and exploit short lifetimes. one can't dismiss a viewpoint that it's complicated, by mentioning its complications as reason that it's needed
 
Xeo
@LucDanton: I noticed that even with Step != 1, the indirection through an array works. Alias<decltype(it)[]>{(void(Is), std::next(it, Step))...}
 
@sehe Done as well. Though the first one arguably does the most damage. Would you agree to remove all links to the transcript after a few hours?
 
11:33 AM
advance does not return the iterator.
 
std::next(it, Step) is the generalization of std::next(it).
 
@Xeo next does not mutate the iterator.
 
Xeo
fuckit.
Write your own "advance and return" then. :P
 
@Mysticial Nope. Like I said, putting the basic context out there is really a big thing in keeping things in proportion. Really, what is your motive for removing it? I mean, you got 12 upvotes for a nice, but excentric, question. I think it's really fine. I predict you will continue receiving many upvotes for this as it is
 
Hint: +. Or ,.
 
11:35 AM
@Mysticial are you leaving this one purpose?
 
@Xeo Welcome to weeks ago. What's the array for?
Hey that line is pretty good example of the horror of the explicit tuple constructors.
 
@sehe Oh right. The problem is that if I don't leave that, it'll look like I ruthlessly stole it from you. And that's just gonna attract plagiarism accusations. That is far worse than a couple of downvotes.
 
@Mysticial Wokay. Clear
 
So either we cut all links to chat. Or I leave that disclaimer to protect myself.
 
@Mysticial ^^
 
Xeo
11:37 AM
@LucDanton When calling a function, you can't easily get right evaluation order.
 
tuples::apply(f, /* do some slicing */)!
Unless you want uncurry? Forgot what the OP wanted.
 
Either that, or we just delete the entire question and disassociate it from my account.
How about this.
If you clear those comments, I'll edit the question to leave a link to the transcript clarifying that it was a trivia question.
 
Xeo
@LucDanton The OP in the question I linked wanted f(args[0], args[1], ..., args[N])
where args is a vector.
 
Oh ya, uncurry.
 
Xeo
Whatever that does.
 
11:40 AM
Opposite of curry. Not that I have it though.
 
Xeo
How does uncurry help if you want to expand a runtime container?
 
@Mysticial It's only the nets. And only virtual rep too. I say, what about we leave it as is. What is the big deal. This is how things transpire all day long on SO
 
@Xeo If that is a problem it doesn't come from uncurry itself obviously.
 
@sehe Well right now, if you read it, I'm being called out for blatant plagiarism literally. That's not good.
 
I.e. can you type-check it?
 
11:43 AM
@Mysticial I don't see the problem there. You explained your side, No one seems to attack you for it
 
Xeo
> "Monotonically increasing indices must be used for a single-pass range"
Hm.
 
Well yeah!
 
If I capture a function object as a template argument. Then how can I create a packaged_task from that? My code.
 
@StackedCrooked If you don't want to settle on the one signature just yet then you can't use std::packaged_task.
 
@Robot interesting methods :)
 
11:46 AM
I see.
 
@sehe Well, there is imguring on answers, but not on comments.
 
@StackedCrooked the template argument from packaged_task is the signature.
 
@StackedCrooked Would it make sense to accept Functor&& functor, Args&&... args here? Then the task you want is std::package_task<Functor(Args...)>, modulo tweaks.
 
@bamboon It's the signature.
 
Or just Functor() if you want to put the burden of binding the arguments on the caller. (Then you keep the signature you have.)
 
11:47 AM
How about, if I add: "Originally a trivia question from here: http://chat.stackoverflow.com/transcript/message/6169551#6169551" to the end of the question.

Could we clear all the comments with this?
 
@R.MartinhoFernandes right, right
 
@R.MartinhoFernandes I found out that you linked to it in comment. I understood :)
 
@LucDanton Yeah, I would make sense to do that.
Cool.
 
Xeo
Hm... I'd really like to have an array of references right now. :s
 
std::packaged_task<Functor&(Args...)> task = std::bind(std::forward<Functor>(functor), std::forward<Args>(args)...); would do it I think.
@Xeo std::ref?
 
Xeo
11:50 AM
@LucDanton That doesn't work too well for temporaries
 
Oh, I assumed lvalue references.
 
This here says there's two's complement for int64_t. That's wrong, right?
 
It's weird. The specs I mean.
 
Bias 2^63 would work, I guess.
 
11:51 AM
Some representation is mandated but I don't know what that guarantees you exactly :/
 
@LucDanton I was originally planning to require a function that takes no arguments (so the user has to bind them into the function object) because of simplicity. But this should be better.
Lunchtime.
 
Well it's more convenient but it's just as expressive.
 
@LucDanton Apparently the C99 standard requires two's complement.
Weird.
 
Does it? Do you have a ref?
 
@LucDanton I think the Functor in your packaged_task template arguments is wrong. Shouldn't it be the result_type of Functor there?
 
11:56 AM
@bamboon Could very well be.
 
Yeah, should be, typename std::result_of<Functor(Args...)>::type
 
Functor&
 
@LucDanton ok, what does that help here?
 
Actually it's even Functor& and Args&..., std::bind is really annoying here.
 
@bamboon rvalue-ref-qualified overloads and shit.
 
12:03 PM
Well no.
@Xeo Hey I've investigated your min_arity thingy as you asked and it appears that GCC doesn't recurse when instantiating the fallback eval. No idea if this is conforming but regardless I went with the usual workaround: added a typename Self = invoke_test parameter and explicitly qualified the call.
 
Xeo
Oh, cool.
 
Now there's a 'template instantiation depth exceeds maximum of 900'. Which I think is to be expected.
Usual 'unspecified whether templates are instantiated during overload resolution' thing.
 
Xeo
Actually, no. oO X::operator() takes 3 arguments
ew.
 
You suck.
 
Xeo
I forgot that. Fuckit.
 
12:09 PM
Adding an ellipsis doesn't help. I'll try specializations.
 
Xeo
I have an idea...
Do you have the ideone link handy I gave you yesterday?
 
Xeo
yep, thanks.
 
Partial spec doesn't seem to do any better.
 
so by the tag line, can I take it that @DeadMG has said that, or has someone assumed that?
 
12:15 PM
Kinda bummed, I feel like I'm overlooking something.
Doesn't feel right to blame GCC either.
lol, you used decltype(void(), c). You suck!
 
Xeo
What?
 
template<typename Sfinae, typename F, typename T, typename... Args>
struct invoke_test{
  template<unsigned I, typename Self = invoke_test<void, F, T, Args..., T>>
  static auto eval(Uint<I>) -> decltype(Self::eval(Uint<I+1>{}));
};

template<typename F, typename T, typename... Args>
struct invoke_test<Void<decltype(std::declval<F>()(std::declval<Args>()...))>, F, T, Args...> {
  template<unsigned I>
  static auto eval(Uint<I>) -> Uint<I>;
};
This compiles.
 
Xeo
What's wrong with decltype(void(...), c)?
 
Yeah it's silly to use a function template here but you know, incremental changes.
@Xeo Can't inherit from Uint<I>&.
 
Xeo
Ahahaha, oh wow.
 
12:26 PM
template<typename Sfinae, typename F, typename T, typename... Args>
struct min_arity_impl: min_arity_impl<void, F, T, Args..., T> {};

template<typename F, typename T, typename... Args>
struct min_arity_impl<Void<decltype(std::declval<F>()(std::declval<Args>()...))>, F, T, Args...>
: Uint<sizeof...(Args)> {};

template<class F, class T>
struct min_arity: min_arity_impl<void, F, T> {};
Short(ish) and sweet.
 
@Xeo the comma?
 
Xeo
@LucDanton I'd really have liked if the original version just worked. :(
 
Well I'm not saying it shouldn't work or that it couldn't be made to work.
 
12:40 PM
sup guis
it's boring
 
conference about the scrotum?
 
Scrum sorry. Typing on mobile sucks
 
Srsly guise!
 
i am jealous because all the mvp's in norway have a free dinner in oslo tonight. but not me, since i'm up north and not very mobile (surgery). argh!
 
@Cicada Likely having your thoughts forced through a straw, right?
 
12:48 PM
@R.MartinhoFernandes maybe she also invoked speling corektion
on the other hand, they're going to Friday's and I think the only food I can remember worth eating there is the "New York Strip", whatever that is
 
That's why I don't do two shows a night anymore...won't do it.
 
@Cheersandhth.-Alf What the heck is "New York Strip"? Meat?
There was no animal in today's lunch. Luckily the dessert was good.
 
the internets very slow
 
user1182183
aaaaw yeaaah, linux version compiled ;D
 
12:57 PM
Oooooh, steak.
 
i think they also have spare ribs
oh i must be hungry talking food all the time
 
> There are a couple of differences but the system worked well so for months and I have any doubts that it has any flaws.
"This is crashing, but I am sure it has no flaws"
 

« first day (774 days earlier)      last day (4188 days later) »