« first day (920 days earlier)      last day (4254 days later) » 

09:00
@Xeo What was so evil?
Xeo
Xeo
Nothing. Just people being confused by std::bind
@Xeo Why would you need std::bind, as in what do you do with it?
Xeo
Xeo
4
Q: std::function and std::bind behavior

FelicsI have this code: #include <iostream> #include <functional> #include <vector> void fun() { std::cout<<"fun"; } void gun(int) { std::cout<<"gun"; } int main() { std::vector<std::function<void(int)>> vec; vec.push_back(std::bind(fun)); vec.push_back(gun); vec[0](1); ...

4
Q: Understanding std::function and std::bind

pacificatorI was playing arround with std::function and std::bind and I noticed something unintuitive and I would like to understand it better. For example: void fun() { } void hun(std::string) { } int main() { function<void(int)> g = &fun; //This fails as it should in my understanding. function<

Wait, dupe?
Or just more specific?
Hi
@Xeo hehe
Xeo
Xeo
09:04
> It is invariant that operator []( 0 ), front() and back() shall return terminating character for an empty string. It is a very artificial, useless, and only confusing requirement that back and front may be applied only for non empty strings.
Oh gawd this guy....
he's right
Xeo
Xeo
what
he
is
correct
Xeo
Xeo
ITT: Puppy gone crazy from all the Unicode.
Nope. back() is [size() - 1], how can you expect that to work on an empty string?
09:07
ah yes, not back().
but front(), I can completely see his point.
Xeo
Xeo
front() doesn't make sense either
the spec for op[] requires the behaviour he wants, it's just that front arbitrarily removes it
Xeo
Xeo
front() on any range that is empty is UB. Why should it be different for std::string?
I don't think it's arbitrary, keeping in mind you're not allowed to modify the terminator but you can still access it non-const.
@Xeo Why does std::string::operator[](s.size()) return a valid value?
Xeo
Xeo
09:08
Because str[strlen(str)] does for C-style strings.
FWIW, I'm completely with this guy and his explanations: groups.google.com/a/isocpp.org/d/msg/std-discussion/JxISdlv_95A/…
there you go then
@GamesBrainiac Erm. That came out of nowhere. Assuming tie of string<char>, I'd suggest a large vector<char> with appropriate index
I.e. I expect a lot of code that would want to call front() unconditionally would also touch it. And it's a no-no touch.
Xeo
Xeo
@DeadMG That doesn't imply the behaviour of front().
so the front value of an empty C-style string is the NULL terminator.
09:09
Except that it isn't, because the \0 isn't really part of the string. It is not required to be there at all times
Xeo
Xeo
C-style strings don't even have front in any form. front is part of the container-interface part of std::string, not the string-interface part.
I repeat:
2 mins ago, by Xeo
front() on any range that is empty is UB. Why should it be different for std::string?
iirc, anyway, and I don't want to doublecheck the spec because std::string's semantics regarding the terminating null byte are painfully subtle
@DeadMG Cue Bjarne quote regarding the importance of not allowing things.
"This is why you can't have things @DeadMG" -- The Bjarne
I'm all for allowing less rather than more
@DeadMG You can't have that.
09:12
@EtiennedeMartel HURRY UP AND GET DARK SOULS SO WE CAN ENGAGE IN JOLLY COOPERATION. <333
all I'm saying is that having a function which is identical to operator[](0) in every respect and conceptually should behave identically but has an extra precondition is not helpful.
4 mins ago, by Luc Danton
I.e. I expect a lot of code that would want to call front() unconditionally would also touch it. And it's a no-no touch.
Makes it not the same.
Xeo
Xeo
It's not identical because it's not part of the string-interface.
@Neil That's just the obviously bad stuff. Then, there is the rest. Starting with intrinsics deriving from Object
Xeo
Xeo
It's part of the container-interface
Just because it's described in terms of another thing doesn't make it the same.
09:14
We're saying it's not just the result that makes the function, it's also what it's for.
well
@ScottW Whyyyy?
I guess I could see the argument that there is no generic code that does cont[cont.size()].
whereas there could well be lots that does cont.front().
@DeadMG generic code which calls front on empty sequences?
Xeo
Xeo
09:15
@jalf It's not only about empty anymore
But also about the null-terminatore being returned
Damnit, where is the original comic
Oh my 4 hours
Xeo
Xeo
2 mins ago, by Luc Danton
4 mins ago, by Luc Danton
I.e. I expect a lot of code that would want to call front() unconditionally would also touch it. And it's a no-no touch.
ah
I'm sick and tired and got too much work to do
ignore me
Xeo
Xeo
lol
09:16
> can divide the operations on std::string into sequence features (part of the sequence concept), compatibility features (C interoperability and transition), and bloat^H^H^H^H^Hstring-specific features (operator +=, find_first_of, etc.)
lol
Xeo
Xeo
:)
Xeo
Xeo
(:) 42 []
@ScottW "Every object shall contain a big fat bloated base class stuffed full of design flaws and things you rarely need", yeah, that's just awesome. :)
09:17
@jalf Q_OBJECT?
fucking object comes with its own compiler
I can't even imagine how much less memory Java apps would require if they'd used a sane base class
@Mikhail Hmm?
Yeah, but without pointers its hard to hash?
@Xeo No instance for (Num [a0])
I wonder if Java hashing can be exploited to find memory addresses and then escape teh sandbox
@Mikhail Pointers? Hash? Wat?
Xeo
Xeo
09:18
@LucDanton Ack!
@jalf I can make a uniqueness function with a pointer (under some assumptions)
@Mikhail Yes, but why is that at all relevant? You could still have pointers if all the fat was trimmed from the base class definition
@jalf hashCode()
Returns a hash code value for the object. ?
@Mikhail I'm certainly not arguing that Qt is an example to follow. Just pointing out that every object in Java has to contain an awful lot of garbage bytes, some of which can practically only be used incorrectly
@Mikhail again, what does that have to do with anything?
I think the hashCode() function is needed as a replacement for pointers
09:20
/me head asplodes
Off the deep end.
@Neil Wait, did you change the comic? I could have sworn it was about japanese girls five minutes ago.
Ok, take a step back. Then take another 200 steps back. Now explain to me from the beginning what it is you're trying to say, and what it has to do with what I said
Oh god. We still doing this stuff?
I thought language wars had officially become old
Because I haven't got the faintest clue right now what you're trying to say
09:21
"If Java had true garbage collection, most programs would delete themselves upon execution." -- Robert Sewell
@sehe You wish
... litterate programming
Indeed I do
@sehe WIDE DA BEST!one1
lol. War is no joke! And, a joke is no war!
Girls
@sehe War. War never changes...
09:23
@jalf It will do when we send Terminators to fight instead of human soldiers.
1
A: Are there generic smart pointers?

rubenvbSome misconceptions lead to an awkward code style: Smart pointers are as generic as raw pointers: you can treat them much the same when calling functions of the pointed-to objects. If you really need to pass them to functions taking a raw pointer (and those functions will not take ownership), y...

@ScottW do it again
@ScottW Play Dark Souls
Just fly by dropping my answer here. I feel the other answers fail to solve the underlying problem.
Praise the Sun
3
09:24
#praise
#jollycooperation
I need to get Havel's ring
lol that post at starboard
You get it in the Watchtower at the base of Darkroot Basin
09:26
10 hours ago, by DeadMG
Bartek is far from a master of the template metamagics
problem?
Yeah I know where he is
If I want an Object base for everything, and all objects dynamically allocated and represented by pointers, I would use Delphi rather than Java. Do I have to get Dark Souls now to be a 'real' lounger? I've heard that you fall through the floor, lose all your souls and go batshit crazy.
@DeadMG lol, no
I paid him a visit when I was looking for Lower Burg
:v:
09:28
You are absolutely right, of course.
Lol, you kicked his ass? :D
It was somewhat like "whew I cleared the tower surely I'm safe kachunk kachunk kachunk OH GOD HE'S STILL BEHIND ME"
Also, I think I'm going to stay level 20 forever.
If I kicked his ass I'd have the ring and I wouldn't be a turtle in the Elite set :<
@CatPlusPlus Roflmao. The Heavy Footfalls of Havel : A CatPlusPlus Vignette of Terror and Adrenaline.
09:31
Also the autolock on Gaping Dragon is terrible
Yeah, it's kinda wonky.
But works well for Magic.
Magic OP. <3
It's 11:30 on a tuesday. Time to get wasted and watch little mermaid.
Always firebombs
@CatPlusPlus Pffffff. You and your firebombs.
Real men use staffs and wands.
So, with all this talk of Dark Souls, here's how the very first reviewers survived
09:33
Hmm.. I have only ATI 4800. For DS I may have to get another card :((
We're cheesing this game so bad
We even cheesed PvP
@CatPlusPlus Pity. I think the most unique part of the game the exploration and discovery. :)
By the way, anyone here fluent in Obj-C?
here, have this photo of our site
@jalf Yep
lounge is too calm today. Where are potatoes
09:40
@BartekBanachewicz Look at my commits if you're bored :)
@jalf There's less for me to discover because I've played it a few times through (not past like, Anor Londo though)
@kbok wwaaaaa
I think CatPLusPlus knows what's up, though,e ven though it's his first time playing through. How is he all up on the whereabouts and everything? >__>
tbh I have to leave for uni soon, but I want to empty my mind before
... before I shout at someone there.
Hmmmmm? Hooow do you knooow the seecreets, Caat?
09:40
@ThePhD he's a powergamer
@DeadMG Yep, found a copy of the original that had been modified
@ThePhD sure, I meant for people who are new to the game :)
aaaaaa COMMIT
But yeah, we totally cheesed on PvP.
The phantom invaded and was like "YES I GOT THIS NOOB IN THE DEPTHS"
09:42
@kbok I am listening to some 13yo rebel rock now.
But then, THE BRILLIANT RADIANCE OF A SUNBRO SHINETH DOWN UPON HIM
AND HE REALIZED, CAT WAS NOT ALONE, FOR HE HAD THE BRIGHT SUNBRO LIGHT OF JOLLY COOPERATION, BEEEEEAMING DOWN ON HIS WORLD!
@kbok does it ever start to... feel natural? When I look at it, it is chock full of special cases and little rituals you have to do to opt into some feature added in this or that version of the language, new, different syntaxes for basically the same thing, and seemingly overlapping features (categories, class extensions and a couple others, I believe?)
Why don't you use boost::archive::binary_[io]archive, Boost Spirit binary parser epressions or e.g. protobuf? The field is fraught with opportunity for errors and UB. — sehe 1 min ago
I feel like I have to consult a reference cheatsheet constantly
Backstabs own
09:43
@ThePhD oh god I should've seen this comming when I used caps, huh
@BartekBanachewicz It's viral~
and it's not just because I'm new to the language (since I don't get that feeling from other languages I'm learning)
@ThePhD Geop's LP
@jalf My feeling is that the "extra nails onto a dog" remark applies much more to Objective-C than to C++.
@kbok er, what does that mean? :D
09:44
@CatPlusPlus Ooh, that. Well, don't watch the whole thing! Just let yourself explore some places first. It's fun that way. :D
It's fun to watch!
@jalf Objective-C is, IMO, really just a BUNCH of preprocessing on top of plain old C.
I think I see what you mean, but never heard that phrase before
Sen's Fortress is gonna be a nightmare to do. =[
@kbok trololol
09:45
@kbok yeah, that's my impression too. But seems like they're also not very smoothly integrated into the language
Kind of a pity, because at its core, I think it's a pretty cool language
@kbok There is so much hypocrisy and irony in that one, that I can't but assume you did that on pupose
@jalf Yeah. Also regarding "feeling natural", well, I've been working with it for 6 months and no, it doesn't feel natural. The only relief is the IDE support.
@sehe he summed up the UX quite well though
12 hours ago, by sehe
@kbok ?! Wut. No. It's just "SQL" inside your C (or C++) source, being pre-preprocessed into ANSI C
@StackedCrooked So, the way you keep your std::promise alive is to use a shared_ptr and to pass it in by-copy to the lambda?
09:47
@sehe hahahah :P
Objective-C feels a lot like smalltalk
@sehe I know what you're saying, and I think we just disagree on the "integrated" thing. Both are glorified preprocessors IMO
@jalf You seem to not know what I referred to, which is okay :)
@sehe yeah, I was deep asleep 12 hours ago. Thanks for oneboxing it now :)
I think I get it now
Objective-C is that big patchwork of features cobbled into a compiler.
09:50
@jalf Yeah. I thought it was funny that last night kbok was defending something I would label as "just preprocessing" as "well integrated into language" (dubbing it "LINQ for C"), and now, he'd detract from an obviously integrated language saying it "is, IMO, really just a BUNCH of preprocessing on top of plain old C".
There was such a major clash there
@kbok (But! It's cobbled into a compiler. Making it a lot more integrated by definition)
All that aside, I think my first big "Aha" moment with Obj-C was when I realized that "this is (or started as) basically just preprocessing stuff on top of C". Once I thought of it in those terms, it suddenly became a lot clearer what was going on under the hood
C++ was "basically just a bunch of preprocessing stuff on top of C" (Stroustrip, EDG)
Yeah, but emphasis on "was"
@sehe Drop the well and yes, that was my point. But I'll have to point out that "integrated" != "natural"
IOW Pro*C and Objective-C are integrated but neither feel natural
@kbok Well, within my definition tolerances, Pro*C is not integrated (it's an extension) and Objective-C is integrated.
09:55
OTOH C++ feels natural once you distant yourself enough from the C aspect (IMO)
@kbok True that. I was just saying (note "was")
@sehe We may differ on what "integrated" means then.
@kbok I was pointing that out/confirming that.
in Lua C++ API project, 1 min ago, by ankitmakwana
Any one in Android here
...
Boot him. Kick him. Ban him.
... oh well, ignore him
09:59
@DeadMG lol
@DomagojPandža 7/10 would bang? :)
You guys have been overusing that tag meme to death.
Oh BTW @R.MartinhoFernandes what's wrong with std::function?
gives you herpes
10:06
@kbok It's overused, like memes
That's not an inherent defect though
Functors carry inherit mystery state
@kbok Nothing. But using it as something other than a container for a callable of known signature is abuse.
Why is everyone yelling at me then
@R.MartinhoFernandes s/Nothing/Allocators/
10:09
@DeadMG ?
the type-erased allocator model used in std::function is broken
it's not something users do much to replace that allocators, but still
@kbok I'M NOT YELLING AT YOU!
yet
@R.MartinhoFernandes I honestly forgot the details almost as soon as I heard them, it's something to do with what happens when you assign and both src and dest have different custom allocators.
Meh, that sounds too niche-y for me to call it broken.
@kbok Because IIRC you were doing function signature introspection to return std::functions.
If you need to do introspection you don't have a known signature anymore.
10:17
@R.MartinhoFernandes Well, "known signature"... The compiler knows.
Doesn't count.
If you don't have a known signature std::function offers nothing.
It's just wrapping for the sake of wrapping.
It offers a unified interface for callables
@kbok Not if you don't know the signature.
What? It doesn't offer an interface? It's not unified?
@kbok It's not unified if you don't know the signature.
10:20
@LucDanton Yeah, well, kinda but not enough. I didn't get it to work (unless with the "//CHEATING" line) ideone.com/NbEPJR
Yes it is. It's much easier to work with function<T(P...)> than with obscure callable types
To be fair, I don't grok the trick about making a trait SFINAE-friendly. I'm willing to learn that, even if it takes some time. And feel free to just point at a good source of info instead.
@kbok HOw the fuck is it?
@kbok Define "obscure callable types". It's just functions or objects, really
It's the same goddamn interface: op()
some_std_function(a, b, c) and some_callable(a, b, c) are the same thing.
10:22
Not if you want to inspect the parameter types. Inspecting is the goal, not a means to an end.
Why is that goal?
Are you doing homework?
Because we're generating wrappers for a foreign interface.
(Plus, you don't need std::function to inspect anything, only type traits)
@R.MartinhoFernandes Granted
And you don't need to inspect beyond the return type (std::result_of).
10:26
Yes we do. The foreign interface wrapper fetches values from the C api which is completely type-erased and produces values for the parameter list. Knowing the type lets the wrapper check the validity of the parameter and produce acceptable values for the call.
hm... make_unique doesn't accept deleter. that's bad.
@Abyx FWIW neither does make_shared.
but there is something... allocate_shared?`
Only allocator.
hm... that sucks
Xeo
Xeo
10:30
0
A: Are pets allowed on Stack Overflow?

MelkiAs long as we authorize insects (like bugs) I see no reasons we don't allow cat.

ahaha
@Abyx damn kitties in proposal: "kitty.cpp", "meow"
Xeo
Xeo
@Abyx For make_shared, it makes sense, and for make_unique it's more of an interface thing
@EvgenyPanasyuk that's the STL
Hi Xeo, I have a bit of time during my lunchbreak now to hear your story about the std::function dropping extra arguments
Xeo
Xeo
10:32
@EvgenyPanasyuk STL: "I love having a job where I get paid to make cat-noises all day." - somewhat paraphrased.
@rhalbersma Not std::function, std::bind
@Xeo I heard something similar from him, in one of his videos..
Xeo
Xeo
Ya, that's what I'm referring to
@Xeo, yeah, std::bind dropping them
@Xeo typing unique_ptr<Long::Type::Name, void(*)(Long::Type::Name*)> kinda sucks =\
@kbok Hmm, I'll look at it later then. (still wrapping in std::function gives no benefit)
10:33
@Abyx decltype would help a bit
only a bit
Xeo
Xeo
@rhalbersma §20.8.9.1.2/3 "Returns: A forwarding call wrapper g with a weak result type (20.8.2). The effect of g(u1, u2, ..., uM) shall be INVOKE(fd, v1, v2, ..., vN, result_of<FD cv (V1, V2, ..., VN)>::type) [...]"
meh, whole C++ is fucked =\
Xeo
Xeo
And p10: "The values of the bound arguments v1, v2, ..., vN [...]"
So it only forwards bound arguments to the bound function
we need more type inference
10:37
@Xeo, I see, so it hinges on the definition of bound, which is left unspecified AFAICS
Xeo
Xeo
template<class F, class... BoundArgs>
unspecified bind(F&& f, BoundArgs&&... bound_args);
Not really, I'd say.
@rhalbersma Erm did you read p10?
Xeo
Xeo
I should probably have left "where the values and types of the bound arguments v1, v2, ..., vN are determined as specified below." in the first quote.
@Abyx FWIW, Luc has make_unique(raw = ..., deleter = ...);, but the standard doesn't seem ready for named arguments :)
...and different syntax, yeah
10:42
@Xeo @R.MartinhoFernandes Got it now, the bound arguments are known when the std::bind expression is created, and are not dependent of the actual parameters that are passed to the point where the function is called
like f(arg1, arg2, *va, **kwa)
Xeo
Xeo
I don't get the Python vararg syntax.
@rhalbersma Right.
Xeo
Xeo
Never really bothered, though
It's a bit like eval/apply where the late arguments is the environment to lookup the bound arguments. But not really.
10:43
@R.MartinhoFernandes I simple example in the Standard to illustrate that would have been nice. At least the boost::bind docs do that.
@rhalbersma The Standard is not a tutorial/intended for users.
@Xeo thanks for the explanation, it's not that roundabout that it wouldn't have fit in your answer, IMO :-)
Xeo
Xeo
Well, actually I wanted to head out for lunch, so I didn't have time :P
I'll add it to my answer (later)
@LucDanton I know, but there are many other illustrative snippets. BTW, is there any online repository of all the code snippets in the Standard that one can use to test a compiler of choice?
...installing C++ Builder XE4...
10:48
@rhalbersma The Committee is explicitly against setting the Standard up as a tutorial.
@DeadMG I get that. A simple line indicating that actual parameters at the call site can be silently ignored is not really a tutorial, is it?
It is.
user1357851
Xeo
Xeo
I think examples in the standard are only intended for clarity, and anyone fluent in Standardese should see how bind's returned object ignores unbound parameters.
user1357851
10:56
What if the female is the most elite troll?
Xeo
Xeo
Anyhow, GSQ added.
@Telkitty lol, in your dreams

« first day (920 days earlier)      last day (4254 days later) »