« first day (320 days earlier)      last day (4618 days later) » 

8:01 PM
 
Am I correct to assume that in C++11 you can make a class final (not inheritable) by simply declaring the destructor final?
 
momentum
 
What is it with people trying to force non-inheritability? Can't you just write a comment "This class was not designed to be derived from. If you do, it's your own fault." and be done with it?
 
@FredOverflow: currently it's just curiosity ;)
 
It's a fine line between preventing inheritance and having an abortion.
 
8:09 PM
But I can assure you there are people inheriting from std::vector in production code in large projects so it's not a completely silly thing to do
 
double negations are silly
 
my mistake :)
 
No, the original intent was that standard containers be heritable. According to Stroustrup, the language simply didn't support it properly until C++11. (Inheriting constructors.)
 
@KillianDS meh inheriting from containers is a mistake
 
@TonyTheTiger : Yes it is, doesn't prevent it from being in production code
 
8:11 PM
true that
 
@KillianDS Why would i want to inherit from std::vector?
 
cause maybe the vector has lots of money and you can inherit it?
 
haha
 
oh noes, programming != real life
 
8:13 PM
struct fogey { protected: double pot_of_gold; };
 
I believe it's in his FAQ somewhere.
 
google fail :(
 
Now, was my assumption of making destructor final correct (the issue if it's something you should use in production code aside)?
 
@TonyTheTiger It knows what you've been searching for most frequently.
 
8:15 PM
Do you mean private?
 
Well, the destructor is pretty final.
 
@CatPlusPlus lol, this came from reddit, not me
 
@LucDanton final is a function specifier that hasn't yet been implemented by any compiler
 
Won't that require a virtual destructor though?
 
you know what really pisses me off?
 
8:17 PM
@TonyTheTiger sauerkraut?
 
Penguins?
 
@CatPlusPlus they're cute :P
 
@KillianDS I don't see why that would work, destructors aren't inherited anyway, right?
 
final does seem to require virtual.
 
I've watched TB's WTF is on the new Deus Ex, and now I want to buy it. Whyy is it so expensive, whyyyyyyyy.
 
8:19 PM
Well anyone who's "serious" about managing their inheritance uses virtual ofc :vP .
 
So is this about enforcing a class of a hierarchy to be a leaf or restricting inheritance in the general case?
 
:1374611 I once got a reaction only 5 months later. They asked me when I could begin working for them.
 
@StackedCrooked wtf? really? damn, why does it take em so long?
 
2
Q: Wordpress doesn't allow me to post in really old dates (year 1800)

RodrigoI'm making a timeline in Wordpress, and I'm trying to make a post with the date January 12, 1800, but Wordpress doesn't allow me. Apparently, it doesn't let me post anything before the year 1970. Is there any way to fix it?

 
Private constructor makes a class non-inheritable. You need to add a public static factory method however.
 
8:20 PM
lol
 
where they surprised you'd long found something else?
 
@FredOverflow well, I was wondering about that (let's assume of course you declared it virtual). If a destructor in an inherited class is provided (default or not), does it override or not?
 
Actually, there's nothing preventing an implementation from ignoring the virtual specifier if the function is final and doesn't override anything. (Except maybe ABI obligations, but not really.)
 
Hi
Got my C++ books today.
 
@TonyTheTiger The company was also hiring a director of development at that time. And they were also moving to Gent. Due to all this they didn't have time to hire me at that time..
 
8:22 PM
@StackedCrooked oh ok
 
10.3/6: "6 Even though destructors are not inherited, a destructor in a derived class overrides a base class destructor
declared virtual; see 12.4 and 12.5."
 
@Potatoswatter Which is only relevant if you delete a Derived through a Base pointer, right?
 
@TonyTheTiger however, that was probably not a representative case. If you don't hear from them in the first 2-3 weeks then they probably weren't interested and didn't bother to let you know.
 
@FredOverflow The point here is that you can't form a Derived class in the first place, right?
 
@StackedCrooked meh, damn
 
8:24 PM
@TonyTheTiger yeah it sucks :(
Happened to me a few times..
 
Yea, I went to an interview once and they told me they'd let me know, and I never heard back from them
 
On the other hand if they call you and tell you they decided not to hire you then that feels bad as well.
 
I consider that rude
 
@TonyTheTiger to cheer up, you sollicited during vacation period, could take extra time to get back to you
 
@Potatoswatter I thought it was about whether you could inherit destructors at all.
 
8:25 PM
@StackedCrooked yea but at least then you know, I consider that to be politer then not saying anything
 
Are you talking about women rejecting you? :)
 
Yeah, it is politer.
 
@KillianDS perhaps
@FredOverflow I wish, no job interviewers not getting back to you
 
@FredOverflow The quote I pasted says they aren't inherited but they do override. So you can't define a class derived from one with a final destructor.
 
@FredOverflow For some reason women never want to hire me :(
I should perhaps improve my CV?
 
8:26 PM
We've talked about me and women yesterday, is it really necessary I repeat myself?
and then we had an argument
 
@Potatoswatter thanks, was an interesting brainteaser about the behaviour of the destructor
 
@StackedCrooked Cunnilingus Vitals?
 
Perhaps it's me who should be hiring them. Opening vacancy.
 
@Potatoswatter Assume a non-virtual destructor in Base. Why should I not be able to derive from Base and write a destructor in Derived?
 
8:28 PM
Meerkat not giving two fucks
lol :P
 
@FredOverflow We're talking about final destructors, which must be virtual… (Although as I mentioned, that virtual may not imply existence of a vtable.)
 
@Potatoswatter Oh, I didn't know that. So there is no such thing as a non-virtual final destructor?
 
@FredOverflow final is restricted to virtual functions.
 
Is final placed at the end of the member function declaration, just like const is?
 
yes
 
8:31 PM
I find it a bit silly that in order to enforce non-inheritability, I have to use a virtual destructor...
 
If you really want a useless class, make a function final = 0.
@FredOverflow Enforcing non-inheritability is silly in the first place.
It's not the primary purpose of the final specifier. It's intended to double-check that you're overriding the correct overloads.
 
@Potatoswatter So final also means override?
 
@Potatoswatter override is for that.
final is to forbid overriding.
 
Since that guarantee is harder to check for virtual functions.
 
Which is useful if you don't want derived classes to break your invariants.
 
8:35 PM
@RMartinhoFernandes Hence, if you override the wrong overload in a derived class, and step on a final, the compiler will tell you.
 
0
Q: Is it possible to disallow or 'hide' methods to stop the development team using them?

youthinkthisisntmeI work in a team of 20+ developers that includes a recent influx of newer members. Our coding standards state that the .First() extension method for IEnumerable should never be used, and instead that we should always use FirstOrDefault() and check for a null return. I appreciate that some member...

Gosh this is wrong on so many levels.
 
Horse blinders + cattle prod.
 
I really like the idea of crippling the developers expressiveness for sake of "coding standards".
If it were me, I'd just grab FirstOrDefault and implement my own First on top of it. And call it Front to avoid "violating" the standards.
 
@RMartinhoFernandes Did you know that mixing iterator logic with manual management of lifetime in the same class is not a good idea?
 
Er, I didn't consider it, but if I did, I think I'd suspect it.
 
8:48 PM
I wish someone had suspected that yesterday/this morning.
 
Does .First throw an exception, or what's the problem?
 
@FredOverflow Yes, First throws some kind of EmptySequenceException, while FirstOrDefault increases the chances of throwing NullReferenceException.
There's no problem.
It's a stupid idea to restrict that.
 
Some organizations are gonna do stupid things no matter what the language or task, because they decided to hire people they had no faith in to begin with.
 
I'm torn between separating the manual lifetime management into my own optional or requiring that the element type be default constructible now.
 
How much do you have to cheat to get default constructibility?
 
8:54 PM
There's nothing wrong 'except' it doesn't work.
 
There's a bug or there's a semantic problem?
 
Oh sorry. Yes, a bug.
I initialize the storage as new (&arena) T(in->pop()); and by the next statement the destructor for the element has run.
Some time later I get a double deletion when the destructor is run again because the element type is std::unique_ptr<int>.
(in->pop() returns T.)
 
And the placement-new allocator is OK?
 
It's not an allocator, notice the adress-of.
Egad
I done something wrong.
 
I see, but that doesn't mean it's not in charge of getting the memory…
Eh, on the other hand I suppose people don't in practice make new overloads like that :vP
 
8:59 PM
Yay, suddenly everything works.
So protip: std::aligned_storage is a type trait for computing storage. It is not the storage itself.
 
lol
std::aligned_storage<T> arena;?
 
Yep.
Well make that std::alignment_of<T>::value.
Now I'm spooked because I was sure I had an off by one error in my iterator logic but the unit test passes.
Aw, InputIterator requires CopyConstructible.
But my iterator is only copy constructible in as much T is.
This suggests to me that I should move the 'look-ahead' element to the end of the channel.
That would make the iterators much 'lighter', too.
 
Copying an InputIterator doesn't save a spot in the sequence, anyway.
At least, not generically. Think of istream_iterator.
 
@Potatoswatter Due to what I'm implementing that's the one I'm really mirroring.
Since all the innards are mutable already you may be on to something here.
I have to take care of *it++ though.
iterator& operator++(int);?
 
9:14 PM
Yeah, just make it a proxy to itself.
Postfix, prefix, all the same.
iterator const& operator++(int) const; ;v)
 
Well, operator++() actually does the reading/popping.
Not operator*.
As does istream_iterator.
 
Well, that's gonna cause a problem if T isn't copyable, so now it all makes sense.
 
> After it is constructed, and every time ++ is used, the iterator reads and stores a value of T.
I'm guessing istream_iterator requires T to be copyable.
Oh well, time to move the lazy initialization stuff in my own optional and move that to in_channel.
 
9:31 PM
yo momma's copyable
 
@DeadMG yo momma isn't movable
3
 
Dammit, I need 3 more boats for cap. ;(
Also "yo momma requires 128-bit address space".
4
 
lol
yo momma's so fat, the recursive function computing her mass has a stack overflow
yo momma's so fat, the bignum library trying to store the value exhausts the heap
 
Too long. Packs little punch.
 
9:41 PM
heap's a lot bigger than stack
 
yo momma caused a shack overflow
 
Yo momma caused a tsunami.
 
only computer-related yo-momma jokes in here
 
The funnest ones.
 
We have a reputation to maintain.
 
9:43 PM
yo momma's so fat, when she sat on a binary search tree, it became a sorted vector
 
Train-a-brain.
 
Yo momma's so heavy, she can compress a random number.
 
Yo momma's so fat she can't be aligned properly.
 
yo momma's so dumb, she always halts
 
Yo momma's so fat she presses Ctrl-Alt-Del with one finger.
 
9:48 PM
The one-fat-finger salute.
 
yo momma's so fat, she can sell everywhere at once
 
Sell what?
I didn't get that one.
 
yo momma's so fat the only thing attracted to her is gravity
so what's up everyone?
I'm bored...
 
I'm in good spirits that I will be able to implement that parallel prime sieve thingy later tonight.
 
oh good
 
10:04 PM
Cool.
 
derpness
:P
 
Sadly, most of the stuff I'm good at requires bail money.
 
@RMartinhoFernandes Is this rewrite correct?
I have the original if you want to check against that.
 
You left an extraneous go call there.
Line 25.
 
10:18 PM
Is this good, or am I overdoing it?
0
A: Dictionary and array as class vs. instance variables

Cat Plus PlusFirst of all, [] is not an array, it's a list. The issue here is how the attribute resolution and mutable variables work. Let's start with class Foo(object): a = {} b = 0 c = [] This creates a class with three attributes — those are available either through class itself (Foo.a, for...

 
Other than that, seems fine.
 
@LucDanton Of course you'll publish the lib under sane license, riiight?
 
@CatPlusPlus You call that a lib?
 
I mean the channel stuff.
 
10:21 PM
Why?
It's a deque, a mutex, two condition variables. The implementation is not worth it.
 
So we can use it too :P
lol
 
For coolness!
For science!
 
@CatPlusPlus Have a watercraft.
 
For the league of lazy people!
 
for teh lulz
 
10:23 PM
BTW, C++ could sure use automatic tuple packing and unpacking.
 
@CatPlusPlus What in particular?
 
auto (in, out) = make_channel<int>(); (or something) instead of:
 
I'm already confused by first and second for my pair of channels.
 
auto channel = make_channel<int>();
auto&& in = channel.first;
auto&& out = channel.second;
 
Looks like I need a channel_pair or something.
 
10:26 PM
Yeah, first/second isn't very descriptive.
In this case, I find get<0> and get<1> slightly less bad because my eyes are trained to recognized stdin and stdout.
 
Good news everyone: it type checks.
Running 16 test cases...
include/annex/channel.hpp(89): fatal error in "T annex::detail::channel_shared_state<T, Allocator>::pop() [with T = int, Allocator = std::allocator<int>]": std::exception: std::exception
annex/unit/channel.cpp(39): last checkpoint

*** 1 failure detected in test suite "annex"
Welp.
 
What's BOOST_THROW_EXCEPTION?
 
A macro.
 
Well it prepares an exception object initialized from the passed expression and fills it withe filename and line number.
Let me push something recent though.
 
10:32 PM
Ah, cool.
 
@RMartinhoFernandes unscoped enum to int conversion ftw
 
@RMartinhoFernandes Done. Also think of BOOST_THROW_EXCEPTION( expr ); as a fancy throw expr; for fancy exception handling.
 
Yeah, I found that. My Google isn't broken :)
 
Well that's odd. On the first pop the channel is reported as closed.
 
10:36 PM
How would it go through the wait condition and have the container empty?
 
Actually I got confused again.
I.e. I inspected an expected throw, not the one that causes the test to fail.
Just the line auto channel = annex::make_channel<int>(); seems to throw.
 
That's... kind of essential :(
 
You don't say.
The previous unit test does just that and it's fine so I'm not sure I can trust the debugger.
 
out_channel<T, Allocator> in(state);
in_channel<T, Allocator> out(std::move(state));
Why are you moving one and not the other?
Space bar Y U no work?
 
I can't move the two quite obviously.
I could also do two copies.
But I simply don't need the state after the second copy.
 
10:41 PM
Oh, sure.
Silly me.
I'd rename the variables though :)
 
#0  annex::in_channel<int, std::allocator<int> >::~in_channel (this=0x7fffffffd6f0, __in_chrg=<value optimized out>) at include/annex/channel.hpp:219
219	    if(p) close();
(gdb) p p
$2 = std::shared_ptr (count 1) 0x4de270
That count 1 is worrying me.
Well it looks like I unconditionally close whenever an end dies, even if it was moved from.
I assume I didn't see the problem manifest before due to copy elision or some such.
Boo to writing move ctor/assignment by hand.
Well not so much 'unconditionally' but the condition I check against is silly.
 
What would be the condition then?
 
I'm not sure actually.
Let me check std::shared_ptr's interface.
 
The move ctor leaves the moved object empty.
 
> Postconditions: *this shall contain the old value of r. r shall be empty. r.get() == 0.
Yeah.
Red herring then. (The problem didn't go away even when manually setting to nullptr.)
> #1 0x00000000004269d0 in (anonymous namespace)::sieve () at /home/mickk/annex/unit/channel.cpp:67
line 67 is th closing brace of the function above siege
 
10:57 PM
Er, that doesn't make sense.
 
Sometimes gdb points to braces when it's running destructors. I'm not sure it applies here.
Anyway the call to std::async does seem to fire.
Still only one thread though.
Oh right, forgot to make those calls explicitly asynchronous.
Right, now the test doesn't respond.
 

« first day (320 days earlier)      last day (4618 days later) »