« first day (1002 days earlier)      last day (3962 days later) » 

10:00 PM
oh he's edited it now to make it better
 
If I'm lucky, tomorrow I'll hit 4k rep!
 
@rightfold He does; that's the bug.
 
> Why is it error?
ROFL
 
user142019
Arrgh.
 
user142019
10:00 PM
I want to buy a T-shirt online but I don't know whether I need M or L.
 
I'd quite like to hit 100k, but I need to step up my game and quit relying on passive rep
@rightfold Are you a fat bastard?
 
user142019
No.
 
@rightfold Then M.
 
then M
 
That was easy...
 
user142019
10:01 PM
But in stores I sometimes need M and sometimes L.
 
@LightnessRacesinOrbit Why?
 
user142019
Depending on the T-shirt.
 
No, you always need M. When you wear L, you look stupid.
Get M and show off your arm muscles.
 
@rightfold How so? Are you a kleptomaniac?
 
user142019
@sehe Because some T-shirts are too large at L and some T-shirts are too small at M.
 
user142019
10:03 PM
How about S and a corset? :D
 
I'm getting XXL: Let me show off my fire-arm muscles (<-- in the USA, everywhere)
 
user142019
I need XL for hiding my dynamite.
 
user142019
Hmm. Reminds me of that suicide bomber video game we always played in elementary school.
 
See. Brabant is breeding ground for terrorists
 
10:07 PM
anyway
night
 
u2
(that irk)
 
user142019
@sehe Die kweekers wonen allemaal in Rotterdam Zuid eej kul.
 
user142019
inb4 rightfold is racist
 
Roffa/never heard of
Rightfold is racist: he discriminates Shetlands
 
user142019
Ik kan niet wachten tot het kabinet valt.
 
10:09 PM
@rightfold I hate this about jeans, too.
 
@rightfold Have I missed too much
 
user142019
Fuck Samsom.
 
some cuts of jeans require three sizes bigger to be as comfortable
and sometimes even then it doesn't work.
 
@DeadMG What? You're jeans don't show your arm muscles :/
 
the fuck do I care about showing any muscles?
 
10:10 PM
:)
 
user142019
 
user142019
Als ik veel geld heb, ga ik ook met zulke riemen rondlopen.
 
Reminds me of those ridiculous upside down suspenders on women's jeans lately
I mean, seriously. Whoever comes with that shit.
 
user142019
That's cool.
 
it is?! it's ridiculous
 
user142019
10:15 PM
It's handy.
 
user142019
It makes it easier to grab the chick.
 
lol
I mean, this still makes sense:
 
user142019
And it's also fun when they're elastic.
 
Don't tell me you don't think it looks retarded
 
user142019
It's also a great alternative to the wedgie.
 
10:17 PM
It looks like someone forgot to dress after a toilet visit. And this is the typical look: shopjelook.nl/media/catalog/product/cache/1/image/625x794/… resulting
@rightfold bretels
 
user142019
Awesome.
 
user142019
Best women's pants is lack of pants.
 
Best women's pants are in your left ear.
Anyhoops. Let's stop failing to go to bed
 
user142019
@sehe I don't think it looks retarded.
 
You don't troll me :/
 
user142019
10:21 PM
@sehe TIL: you've been a conductor in the past.
 
user142019
(I'm trolling you now.)
 
@rightfold I still am.
 
user142019
Cool.
 
Can I get a sanity check on my answer?
 
@BenVoigt Sure. Latest?
 
10:27 PM
0
A: Object slicing, vector element out of scope

Ben VoigtI like the approach used by AngelCastillo a whole lot, but there's just one thing wrong with it. std::unique_ptr<CBaseEvent>(new CDerivedEvent(blah)) will result in deleting an object of type CDerivedEvent via pointer of type CBaseEvent*. Since CBaseEvent doesn't have a virtual destructor (it i...

Does std::unique_ptr propagate deleters during upcast, or is that only a feature of shared_ptr?
Or is it smart enough to make a deleter based on the actual type of the pointer argument?
 
unique_ptr doesn't decide its deleter, you do.
 
@DeadMG: Assuming the second template argument is defaulted, what happens during upcast?
 
upcast is irrelevant.
the template argument is set.
and cannot be altered
 
When you upcast unique_ptr<Derived> to unique_ptr<Base> (moving of course) how is deletion done when the unique_ptr<Base> goes out of scope?
 
If I hit repcap, get an upvote and delete an old answer with 1 upvote. Do they cancel out?
 
10:31 PM
@Borgleader No.
 
via delete (Base*)p or (saved deleter) delete (Derived*)p
 
@DeadMG Technically there's a default deleter.
 
user142019
And you decide whether it uses that or not. :v
 
@BenVoigt By the deleter specified as the template argument to unique_ptr<Base>.
 
@Borgleader Only if you received the upvote today on the deleter answer
 
10:32 PM
@rightfold Yep.
 
what is it that you don't understand?
the deleter is set by template argument when the type is specified.
nothing can change this at run-time.
not upcasting or any shit like that.
 
std::unique_ptr<Base> p = make_unique<Derived>();
 
@Rapptz True, but not specifying one is implicitly a decision for std::default_deleter<T>.
 
p goes out of scope
 
@BenVoigt std::unique_ptr<Base> - deleter already decided.
 
10:33 PM
@DeadMG there is a default, though
 
the rest of the line is irrelevant.
@sehe Yes, I know that.
 
the object is correctly deleted, or only if virtual destructor, or boom! ?
 
@BenVoigt Oh, thanks
 
Hey hey hey
 
user142019
virtual dtor
 
10:33 PM
how the fuck would unique_ptr correctly delete it if it didn't have a virtual dtor?
"Sorry, I know you gave me this template argument as the deleter, but LOLOLOLOL I'MMA JUST USE THIS COMPLETELY RANDOM OTHER DELETER"?
 
@DeadMG: shared_ptr does... by saving a deleter
 
unique_ptr's deleter is set by template.
 
Only shared_ptr saves in runtime which deleter to choose. unique_ptr has it as an template parameter, so it can't be at runtime
 
set. in stone.
2 mins ago, by DeadMG
the deleter is set by template argument when the type is specified.
 
That's why I came to ask
 
10:35 PM
the deleter type cannot be altered or changed because it's a template parameter.
 
Upcast doesn't remember the original type of the object, it applies the new deleter from the new type.
 
user142019
You can't magically assign a foo<D> to a foo<B>. C++ doesn't work that way.
 
@rightfold Well, unless there's appropriate conversions :)
 
user142019
That's not magical. :v
 
Xeo
@DeadMG Depending on your definition of "changed"
 
10:36 PM
@rightfold Then why did you mention it?
 
user142019
see the cuntext
 
user142019
in the meantime, I'll see my bed
 
user142019
Später.
 
@rightfold: std::unique_ptr provides conversions
 
user142019
It's about the deleter, you silly.
 
10:39 PM
Yes, but could there be an object of type default_delete<Base> that has internally a pointer to a function that calls delete (Derived*)p? Yes there could be. Is there? I don't think the Standard requires it.
 
@rightfold Well, next time, kindly specify that bit of context yourself :/ Obviously, the context made it look like you were saying chat.stackoverflow.com/transcript/message/10594198#10594198 was bogus
 
@BenVoigt Actually, that's not permitted.
 
@DeadMG: I think it won't happen because the deleter isn't copied, it's value initialized in the new object?
 
@BenVoigt Er, no, it's plain not permitted.
the effect of default_delete<T>()(p); must be delete p;.
I would not be surprised to find some requirement about default_delete<T> being empty as well.
 
I think that's what is meant, but the Standard doesn't say delete p;. It says "calls delete on ptr", whatever that means.
delete is an operator, you can't "call" it.
 
10:41 PM
basically the same thing.
 
@DeadMG §20.7.1.1.2 default_delete, ad 3 /cc @BenVoigt
 
Ell
You can't call the call operator eh? ;)
 
@Ell: No, you apply the function call operator, which calls the function.
 
@Ell but you can call it that :)
 
it's much simpler to consider operators as functions and discuss calling them as such.
there's no need for an arbitrary "You must APPLY operators but CALL functions" thing.
 
10:43 PM
that works well for overloaded operators, where there is a function. But the delete operator has a lot of magic in addition to the function call.
 
> ³ Effects: calls bullshit on logic
 
@BenVoigt Well... not really.
 
Anyway, who says delete (Derived*)ptr; isn't a valid implementation of "calls delete on ptr"
 
oh hi Ben.
 
@BenVoigt Consider what happens if I have overloaded operator new and delete for Base and Derived.
 
10:44 PM
Hi Bartek
 
@BenVoigt Because it wouldn't be calling delete on ptr. It would be calling delete on some temporary that would have been the static/reinterpret cast of ptr
 
@BenVoigt The only reason new and delete are language magic instead of functions is because we didn't have variadics for new.
there's no core reason at all why they should be language magic anymore.
 
@DeadMG, there's a lot of magic going on besides the call to custom Base::operator delete()
 
@BenVoigt There's no magic at all.
there's no concept in new T(args); that could not be expressed as a library call in C++11.
and equally so for delete p;.
 
10:45 PM
1 message moved to bin
 
Of course there is, something calls the destructor, and it isn't the deallocation function (which goes by the name operator delete)
 
@milleniumbug No he can't
 
Ell
How would you implement new without magic? o.O
 
@BenVoigt And I could just do p->~T(); to call the destructor without any magic.
 
having an extra hidden function call is magic
 
10:46 PM
well... not really.
since if you consider delete p; as some_func(p);, then there's no reason at all why some_func's implementation cannot call p->~T();.
 
delete ptr; calls ptr->~T() and T::operator delete(dynamic_cast<void*>(ptr))
 
without requiring any special magic.
 
user142019
I want to write something in Go.
 
Go write something
 
some_func doesn't even know what T is in p->~T()
 
10:47 PM
...
 
user142019
go rightfold.WriteSomething()
 
@sehe Thank you
 
@BenVoigt Great, so I can entirely cut delete p; with template<typename T> my_nonmagical_delete(T* p) { p->~T(); T::operator delete(dynamic_cast<void*>(p)); }.
 
Ell
go go gadget write something in go
 
I think there's even more magic, but that should be close.
for one thing, finding non-member operator delete
 
10:49 PM
arguably, that's just ADL.
 
Isn't there the global operator delete that somehow might apply, depending on lookup (I don't recall the specifics sadly). Perhaps this is more related to new, though
@BenVoigt Ah you're going the same way.
 
yeah, I think that new and delete have some pretty funky lookup rules.
 
Which ADL can't quite get you to.
 
user142019
@Ell Tududududu, Inspector Gadget!
 
Hence I say there's magic there, not just a plain call.
 
10:50 PM
@BenVoigt You know, I wouldn't be so sure about that.
you can SFINAE on whether or not a class has a member, you know.
 
Are we still on topic? I think the real question is whether it is legal for std::default_delete to be specialized for UDTs... Which would surprise me
 
if it does, call that, else, call global operator new.
@sehe No, the real question is about whether or not it magically saves you from being a complete moron.
 
@sehe: the real question was whether it's legal for std::default_delete to store some runtime information about the true runtime type of the pointer, the same way shared_ptr does.
 
@DeadMG Not without virtual .dtors, I should expect
 
@BenVoigt There is a very big difference between "It would be legal to" and "You can actually depend on this in a real C++ program".
whether or not it's legal is ultimately irrelevant since no implementation would want to eat the performance cost of the extra indirection, and you can't depend on that behaviour anyway
 
10:53 PM
I think I said you couldn't rely on it chat.stackoverflow.com/transcript/message/10594259#10594259
Well I learned something about why in practice you might want to pay for the extra overhead of shared_ptr.
 
what, because you were too dumb to add a virtual destructor?
 
Besides not being able to manage owning pointers, I mean
Have you never made a pointer to a class you didn't write?
 
@BenVoigt have you derived from a class you didn't write and had no virtual destructor <whistle/> :)
 
I would consider inheriting from a class without a virtual destructor to be program suicide, whoever wrote that other class.
 
Who said I wrote the derived class?
 
user142019
10:55 PM
@sehe boost::non_copyable
 
besides
 
@BenVoigt Well, then the discussion has nothing to with unique_ptr :0
@rightfold not intended to be used polymorphically
 
If I want to have a pointer to a class hierarchy someone else wrote...
 
user142019
Subtype polymorphism sucks.
 
10:56 PM
then contact the maintainer and tell him to fucking fix his shit.
alternatively
 
anyway, can you check whether my answer is now right?
 
you could use something like std::unique_ptr<T, std::function<void(T*)>>.
 
1
A: Object slicing, vector element out of scope

Ben VoigtI like the std::vector<std::unique_ptr<CBaseEvent> > vec; approach used by AngelCastillo a whole lot, but there's just one thing wrong with it. std::unique_ptr<CBaseEvent>(new CDerivedEvent(blah)) will result in deleting an object of type CDerivedEvent via pointer of type CBaseEvent*. Since ...

 
@BenVoigt You can, but you couldn't reliably have them polymorphically even without using unique_ptr, really. Arguably there's not much of a difference.
 
you'll get better efficiency and move-only semantics instead of using shared_ptr.
 
10:57 PM
@Borgleader Don't panic
 
Did you mean move-only semantics from NOT using shared_ptr?
 
@BenVoigt "than from"
 
yes
 
@sehe I have MacFright
 
@Borgleader ©®etc.
 
Ell
10:58 PM
what rep do you need to vote to close?
 
Is it worth having a make_unique-type function that returns std::unique_ptr<T, std::function<void(T*)>> then?
 
@Ell 3k
 
@Ell: None, you just come point it out here in chat, and we pile on with votes
 
well, since you only need it if you are fucking dumb or using the code from someone who is exceptionally fucking dumb
then I would say no, it's not a general-situation thing.,
 
@BenVoigt If you're dealing with naughty kids, yes
 
10:59 PM
brb, nature calls
I don't think std::unique_ptr<T, std::function<void(T*)>> solves it, because it's not properly variant. You'd need to capture ptr inside the functor and have just std::unique_ptr<T, std::function<void()>>
 
nope.
 
which is starting to get wasteful
@DeadMG Is that agreement that the variance is wrong, or?
 
sorry man, I'm playing SC2
discuss later
 
have fun
 
@Ell did you sort out your problems with patch?
 
Ell
11:07 PM
@refp unfortunately I didn't :/
I patched it manually, but the source wouldn't compile anyway
But thanks for the help nevertheless :)
 
@Ell alright
 
lmao. This is such a silly work around. T_T
 
Ell
what?
 
@Ell and; no worries :-)
 
11:14 PM
You know how Java doesn't let you return uninitialized variables?
 
It makes sense though but I think it's silly.
 
should one write a question/answer about why an implementation of std::optional would use something as union {char dummy; T optional_value;}?
I'm bored, that's why I'm thinking of just.. doing something
 
Ell
@Rapptz hmm. I don't see the workaround o.O
It looks perfectly sensical to me. But I'm n00b
 
The commented portion doesn't work but it does if I make it a template
It makes sense, I just think it's a little silly. I don't mind it though.
 
@Rapptz because templates aren't made complete until the first point of usage
 
Ell
11:18 PM
I thought it was because you can't construct a Fuck from an int at the point of definition of make_fucks
 
@Ell Yeah that's why. Like I said, makes perfect sense.
@refp Yeah, I know.
 
Ell
Ahh right cool
 
then.. what's the question?
or maybe there isn't any..
 
Ell
@refp he didn't ask one
No question mark in the past convo :P
 
I'm still kinda hung over, I'll blame that
 
11:20 PM
There were none. I was just commentating.
 
but about the union {char dummy; T optional_value;} in a std::optional that can be used in constexpr, is it an interesting question for people or is it something one will figure out on their own?
 
Does that work for references? :o
I mean, std::optional is quite useful for allowing some sort of "null" reference to be returned via boost::none (No pointers or Dummy objects /o/)
 
Hello, World!
 
user142019
template<typename T>
using optional = variant<none, T>;
 
user142019
:D
 
11:29 PM
Segmentation fault: 11
@rightfold lol, nice
Is that the actual implementation, or is that yours?
 
user142019
data Maybe a = Just a | Nothing
 
Ell
I don't see the point of Maybe
 
Xeo
oO
 
std::optional is kinda like a fancy zero or one element container, one could easily just use a std::vector and achive the same thing really. honestly I don't see what the hype is about
 
Xeo
No
 
11:36 PM
No?
 
Xeo
An optional's storage is internal
Also, semantics
There's good reasons for having Maybe / optional
 
@Xeo sure if we wanna get down and dirty with the internal implementation and such; of course they differ
 
Ell
@Xeo I think Maybe is different to optional
 
Xeo
It's not
 
Ell
Oh.
Then I do see the point of maybe xD
 
Xeo
11:38 PM
Maybe is optional
What did you think it was?
7 mins ago, by rightfold
data Maybe a = Just a | Nothing
It's either "Just something" or "Nothing"
 
Types are all about semantics.
 
the biggest difference when comparing Maybe and std::optional would be that haskell has a "value" for representing nothing, in c++ there's no such thing
 
Xeo
@Magtheridon96 The boost::optional guys considered implementing it as variant<none, T> at one point, IIRC
 
Ell
@Xeo I don't know, some monad functional thing I don't really understand :P
 
Xeo
@refp Eh
You can just make your own value
 
Ell
11:39 PM
^
 
Xeo
Like std::nullopt
 
... of course
 
Xeo
@Ell Maybe is a monad.
 
@Xeo I was just trying to be "funny"
 
Xeo
@refp Also, Maybe's Nothing constructor is also nothing special, or specially handled by the language
 
Ell
11:40 PM
@Xeo well it would help if I knew what a monad was I guess
inb4 "a monad is a monoid in the category of endofunctors..."
 
Xeo
A wrapper with some special operations that carry a context along
The context of Maybe is that it can be empty
 
Ell
Right
 
Xeo
The context of [a] (list) is that it represents many possible results
 
Ell
And the context of io monads is, the io state before the function?
 
Xeo
The context of the IO monad is the "world"
 
Ell
11:42 PM
right
 
Hi all
I wonder is there a way to make sure that a template class implements a method like Java?
 
Yes there is
 
@Chan Read this. Then tell us what your real problem is.
 
I saw couple questions at SO to check if a function exits
 
11:44 PM
will std::optional be made to handle references? the (sample) implementations I've seen doesn't, though I haven't even looked at boost::optional
alright, boost::optional covers it
 
@EtiennedeMartel: Thanks
 
@user21973: are you asking "Why is pausing the whole program causing my program to run slower"? Just think about that for a second... — Mooing Duck 2 hours ago
 
@Chan it's usually not the way to go
 
@Bartek: ?
I think I found the solution to my problem
 
you rarely should check for a one function being implemented.
instead check if the type fits the particular expression
 
11:54 PM
Hm, I want to check if a class implements operator <, or to_string, just like Java make sure a key has implemented Comparable interface
is it the same idea?
 
a bit
Java generics are particularly bad.
 
They're different than C++, but good or bad, I'm not so sure
 
they are bad.
 
Could you give me an example?
 
11:57 PM
well, thing is, you can implement operator< as free function or as a member function.
you are only interested if a < b will compile
 
true
 
template<class A, class B> class is_comparable { using value = decltype(std::declval<A>() < std::declval<B>()); } should do the trick.
 
Here I am
 
@BartekBanachewicz Missing parentheses.
 
but I am not an expert on templates unfortunately
 
11:58 PM
interesting
Thanks anyways
 
and type
and.. a lot of things. ;_;
 
I have to prepare a speech on how bad Java is, with 3-4 winning examples.
Anyone?
 
How bad Java is?
 
quite a lot.
 
I'm sorry but I have to disagree on that
 
11:59 PM
Java is poorly designed.
 
@Jeffrey Jerry has a couple paragraphs running around you can find.
 
Xeo
@Chan It's on Java-level badness
 
@Jeffrey VeryLongNameClassTransistentManagerFactoryProxy = new VeryLongNameClassTransistentManagerFactoryProxy();
 
Probably on Programmers
 

« first day (1002 days earlier)      last day (3962 days later) »