« first day (1601 days earlier)      last day (3362 days later) » 

8:01 PM
For my first job I was given a C++ book at the end of the interview to learn before I started work on the Monday. You're all wusses. — Tom Hawtin - tackline Nov 12 '09 at 17:50
 
chrome.png
user image
8
 
@AndyProwl passing arguments to something that has similar API i suppose... but it's all good, I'm migrating to GCC, fuck this
 
huh... does std::map not offer a 'get key set' function?
 
@thecoshman get what
you mean like std::set<K, A> std::map<K, V, A>::getKeys() const?
 
8:06 PM
honestly, among the newly announced phones...
the only one I'd buy is the one running Ubuntu :\
it's the only one that feels new
I wonder if it's really expensive
 
it appears to be solid and in working order arstechnica.com/gadgets/2015/03/…
solid enough for the CEO to use it as a personal device and give it to the press freely to look around it
 
@thecoshman boost.range has adapters for iterating through the keys in a map, me thinks
 
You can just iterate normally over it....
 
@AlexM. That pretty much just is bubblesort.
 
8:09 PM
@AndyProwl ergh... really...
 
or just iterate normally over the key-value pairs, as Lightness wrote
 
also... is the for(auto& kvPair : myMap) considered 'good practice' or should I use an iterator?
 
it's terrible practice
 
that's where the adaptors become nice
i'd just pair it tho
 
only noobs use non-auto&&.
 
8:11 PM
I use non-auto&&
 
hence my statement
 
if I really need a reference and don't need to mutate the elements, I use const&
 
anal
@thecoshman In general I think range-based for loop is ok. Depending on what the loop does, though, you may consider using a standard algorithm instead of a manual loop
 
@Puppy I was getting more at the weather or not I should use iterators for it...
 
8:13 PM
@thecoshman Iterators are for noobs.
 
@AlexM. from the few pictures it looks like an android clone to me :p
 
@AndyProwl well, I think I want to find a particular element based on on a calculation rather than simply the value... return when I find the first one.
 
who stars anal
children
 
I should look up what the std algos offer :P
 
@thecoshman like...find_if? or what
 
8:15 PM
@melak47 yeah probably :P
 
Yeah, find_if seems to be what you're looking for
 
find_if is nothing like a loop
hmm i'm still here
perhaps i can make a night in of it
quite hungry after all
 
hi
 
I CAN'T DECIDE
 
hey there
 
8:22 PM
@LightnessRacesinOrbit Pizza
 
I'm having an awesome pizza
 
@LightnessRacesinOrbit ikr
 
huh... so I can both std::begin(myMap); and myMap.begin(); :\ handy to know I guess
 
@LightnessRacesinOrbit Make pizza.
 
had loads of pizza lately
lol "make" it no
 
8:24 PM
What a noob.
FF so slow.
 
pizza is over :(
 
Does clang have -dumpversion?
 
dunno, what's that :D
 
prints out version number
 
-v?
 
8:29 PM
no
λ g++ -dumpversion
4.9.2
only the version number
 
it does
apparently.
 
neat thanks
 
but it reports 4.2.1 :v
 
For Clang 4.2.1, it would.
 
nope, it pretends to be gcc :v
 
lol really
 
an old version of gcc
 
that's so bad
 
that isn't even installed
oh my
what is this, the 1990s browser wars?
 
8:32 PM
do they really not have something to just give me the 3.5.0 string?
 
User-Agent: GCC 4.2.1 (Clang, Turbo-C++-compatible)
 
just take the first 5 chars of the -v string :v
 
user3010322
Please enter a positive number to get the number of primes from 0 to that number:
> 100
There are 27 primes between 0 and 100
 
user3010322
\o/ I did it!
 
congratulations
 
user3010322
8:33 PM
(Without BigInteger, because fuck that noise.)
 
@ThePhD so is 0 prime? :)
 
user3010322
@melak47 Yes.
 
is there a proper term for what I called "temporary array idiom" - stackoverflow.com/a/28887182/343443 ?
 
but 0/0 is not 0! :p
 
o_0 "Iterator to the first element satisfying the condition or last if no such element is found." is that saying that if no thing matches... I get the last element returned any way... I presume that is not what happens... but sounds badly worded...
 
8:33 PM
@Rapptz apparently not
"why do you need it" logic -.-
 
user3010322
@LightnessRacesinOrbit Yes. D:<
 
@ThePhD No. There are zero primes less than or equal to one.
It's plainly obvious that 0 cannot be prime, because it cannot be divided by itself.
 
@ThePhD why would you need big int?
 
8:35 PM
@thecoshman the last iterator you gave in, i.e. end() :p
 
57 mins ago, by ThePhD
Even though 10million fits in an int32, why not get FANCY with it.
 
user1804599
use std.io;

proc main() {
    io.writeln("Hello, world!");
}
 
or do you plan to work on numbers that big?
 
user3010322
@LightnessRacesinOrbit 0/0 = 1, obviously.
 
user1804599
My parser understands this woo!
 
8:35 PM
@ThePhD y u troll
 
@LightnessRacesinOrbit ikr
 
@melak47 oh derp, myMap.end() is not a valid 'thing' is it, it's one past the end
 
I need it for CI purposes.
alright -1 for clang
 
@thecoshman don't want to end up in the end bucket of a map!
 
user3010322
@LightnessRacesinOrbit Because it's fun. D:<
 
8:37 PM
@melak47 o_0
 
@Rapptz such a wuss, just parse the compiler agent string :p
 
fuck that
I already do enough insane things in C++
 
Fucking hell, Cities: Skylines.
It has metro in it. METRO.
 
huh... so yeah... doing a find_if and then 'erasing' that gives me correct behaviour. note to self... even if breaking out from the loop after doing it, don't remove something from a map you are looping over.
 
I believe it's called Metro UI now.
 
8:39 PM
@LightnessRacesinOrbit lol: 4.2.1 Compatible Clang 3.5.0 (tags/RELEASE_350/final 217394)
 
@Rapptz I mean the rapid transit system.
But you knew that, you silly prankster.
 
Yep
 
@Rapptz I thought it was "Modern" something or other?
 
user3010322
@CatPlusPlus Quality engineering.
 
@melak47 Oh yeah.
I botched my own joke.
Ah well.
 
user3010322
8:42 PM
Wait a moment.
 
user3010322
Does that mean 1 isn't prime? :(
 
@EtiennedeMartel I haven't played one of them city building games in ages, should I get this one? Looks neat.
 
user3010322
Because I was shown a definition that didn't mention "greater than one"
 
@ThePhD Yes...
 
user3010322
Is this one of those big math debates?
 
8:42 PM
Did you fail elementary school
 
user3010322
Yes.
 
My condolences.
 
user3010322
Is that greater than one clause debated at all or accepted definition?
 
user3010322
Maybe wikipedia can tell me...
 
user3010322
8:43 PM
q_q
 
I linked you to a wiki article of Sieve of Eratosthenes.
 
user3010322
Stupid definitions.
 
It had a gif.
 
@andrepd I've retagged your question per your comment, however your question is more appropriate to C as you're not using C++ idiom. I HIGHLY suggest you pick the language for the idiom you intend to use. — Mgetz 38 secs ago
 
Did that gif had 1 or 0 in it?
 
user3010322
8:44 PM
@Rapptz MAYBE.
 
smh
 
user3010322
Oh, eww, I have to write a matrix multiplier in Java.
 
Everyone over the age of 5 knows that 0 and 1 are not primes.
Except ThePhD.
 
ikr
 
user3010322
WELL.
 
user3010322
8:44 PM
And so should zero.
 
user3010322
1 should totes be prime.
 
Debatable.
 
@Borgleader It really looks like everything SimCity should have been.
The key here is "looks", however. The game isn't out. I've only been watching a few people stream their review copies.
 
8:47 PM
@ThePhD The "generally accepted" reason why 1 isn't a prime is because it makes prime factorisation a bit more "complicated" and the same for other algorithms like the sieve I linked to you.
So.. > 1 not >= 1
 
user1804599
 
guess i'm staying in
 
ok so from the poll: strawpoll.me/3795339/r
half of the lounge gets (almost) nothing
the other half has absolutely no pattern whatsoever
 
cold water is tasty... but cold :\
 
user3010322
From all walks of life and dysfunction! \o/
 
user1804599
8:52 PM
 
user1804599
> Hours: Open today
 
@райтфолд lol
 
user1804599
You can even click it and get the opening hours per day.
 
user1804599
Which appears to be 24/7.
 
"Write a review"
 
user1804599
8:55 PM
@orlp There are reviews:
 
user1804599
> Oh, what an outstanding place it really is, it really feels like the one they showed you in the movies, you know, the screams and anything. feels very real dude. just like the real deal. the room is okay. the food is outstanding, as like gordon ramsay cooked it by himself, but. the wifi sucks. dont be surprised to see your cellphone monthly bill after going here tho.
 
@Rapptz I made this just for you <3
 
lol
 
Xeo
hm, "SteamOS" sale
Stuff that works on SteamOS being on sale
 
9:02 PM
I'm not seeing a sale on Steam
ah there it is
 
you gotta browse it from steamOS, obviously :p
 
hmm there's some not bad games on that list
KSP, PA, FTL
 
Xeo
Isaac
 
huh I suddenly fancy a kebab
 
@EtiennedeMartel I guess I'll wait till it comes out and watch people stream the game before buying it.
 
9:03 PM
@LightnessRacesinOrbit as long as you're not going to shoot it into space..
 
who doesn't want to shoot things into space?
 
user1804599
Me.
 
@melak47 why would I do that?!
Kebab Races into Orbit
 
Wow!
Operation Snow White was the Church of Scientology's internal name for a major criminal conspiracy during the 1970s to purge unfavorable records about Scientology and its founder L. Ron Hubbard. This project included a series of infiltrations and thefts from 136 government agencies, foreign embassies and consulates, as well as private organizations critical of Scientology, carried out by Church members, in more than 30 countries. It was the single largest infiltration of the United States government in history with up to 5,000 covert agents. This operation also exposed the Scientology plot 'Operation...
 
user1804599
9:09 PM
> U.S. Children Getting Majority Of Antibiotics From McDonald's Meat
 
@wilx interesting
 
@LightnessRacesinOrbit What? A kebab? Pissed already?
 
@LightnessRacesinOrbit Damn you, now I have the same problem.
 
Currently you can't redistribute anything VS2015 related, as it's not yet released and the license doesn't allow for it yet. — Mgetz 15 secs ago
 
Eh? All Loungers are drunk but me:(
 
9:12 PM
I'm not
I should be, but I'm still working
 
@Mgetz Oh - you don't want a kebab?
 
@MartinJames I am not drunk.
 
@MartinJames not really my thing tbh
 
@Puppy Try harder.
 
@MartinJames I am perfectly sober (right now).
 
9:14 PM
@EtiennedeMartel I don't understand. You are sober, but still want a kebab?
 
Meta is so weird.
 
@MartinJames not even slightly
 
They're arguing about ?
 
I haven't had a greasy kebab in years
occasionally I'll just get this odd craving for one though
 
39
Q: How can we discuss malicious code?

jpmc26Since we're programmers, security is absolutely something we should all be concerned with. As such, it's important to understand what vulnerabilities to protect against and watch out for, and why certain approaches to them work or don't. In the course of helping other users understand these issue...

 
9:15 PM
@MartinJames 'round here, kebabs are not the ultimate post drunkfest food.
 
see comments
 
also my jaw keeps hurting on one side hmm :/
 
Poutine serves that purpose.
 
@EtiennedeMartel oh.. rite.
 
I would have to be an alcoholic to be drunk at 8am :p
 
9:20 PM
That doesn't follow, kitty
 
No, you'd have to be a programmer
But then again what's the difference
 
right so I ordered it 15 mins ago
estimate another half hour to go hrng
 
@LightnessRacesinOrbit true ... unless it's a hangover
 
9:35 PM
aka polish dexter 80s
 
I'm told that half light beer and half orange juice is a decent hangover cure.
 
Is there any obvious template for RAII with two functions calls (constructor and destructor) without declaring a new class?
 
I'm more of the "drink water and go back to sleep" variety.
 
@BenjaminGruenbaum ?
 
class Foo{ // a short way to write this
     Foo(res){
         take(res);
     }
     ~Foo(res){
         release(res);
     }
}
 
9:39 PM
@BenjaminGruenbaum unique_ptr
 
std::unique_ptr with custom deleter but that makes your class move-only so you have to define copy ctor
 
@Puppy how'd I do it with unique_ptr? I typically only use that for well... pointers
 
RAII wrappers are usually move-only, aren't they?
 
it's called a custom deleter
look it up
 
@BenjaminGruenbaum Robot has an example in the Rule of Zero blog post
 
9:41 PM
struct custom_deleter {
    using pointer = /* my type: use if the pointer is not a pointer */
    void operator()(const pointer& r) const noexcept {
        release(r);
    }
};
 
That just takes care of deletion, not taking the resource.
 
the constructor of std::unique_ptr acquires the resource.
 
@AndyProwl yeah, I read that but that's only half the problem.
 
tbh I don't know what 'take' does.
Seems fairly unorthodox though.
 
take is pretty non-obvious.
 
9:42 PM
but it might be better to make your own class and then Rule of Five it.
 
you have res that you don't already own but then you're going to start owning it?
this is not how shit is usually done.
that's done in a toilet.
 
yeah take seems to be a transfer of ownership.
 
Xeo
@EtiennedeMartel I'm more of the "doesn't get hangovers" variety.
 
well, isn't that like lock_guard works or something? You pass the mutex, the constructor takes it, the destructor releases it
 
std::unique_ptr<decltype(res), custom_deleter> handle(res) should work fine-ish I think.
 
9:44 PM
@Xeo You're not trying hard enough
 
@Xeo Do you say that because you're German or because you don't get drunk at all?
 
Orange juice is the best
 
Xeo
@EtiennedeMartel Because I've never been drunk before.
 
And you call yourself a programmer
Shame
 
@Xeo You have brought forth great shame to your famiry.
 
Xeo
9:45 PM
@EtiennedeMartel Wat
I do drink, but I don't get drunk.
It's just like that
 
@Puppy think std::lock_guard
 
You and your superior German genes.
 
@Xeo I'm not sure whether that's more like a superpower or more like a curse
 
that is not the same thing, as it creates a new resource.
 
I'll think about it - thanks for the help everyone.
 
9:46 PM
it does not take ownership of an existing resource.
 
Xeo
@AndyProwl I don't think of getting wasted as "fun" - at least I've never perceived it that way when people were getting drunk.
 
user1804599
@BenjaminGruenbaum Boost.ScopeExit
 
@BenjaminGruenbaum Might have to make your own resource acquire-er.
 
@Puppy wait what? lock_guard does not take ownership?
 
@Xeo It's fun when everyone is equally drunk.
 
9:47 PM
it does not.
 
user1804599
C++ needs D's scope or C#'s finally.
 
no it really does not.
 
The issue arises when someone gets way drunkier than the others and has to be babysitted.
 
I thought the mutex is the resource it takes ownership of
 
@райтфолд will look into it.
 
9:47 PM
> When a lock_guard object is created, it attempts to take ownership of the mutex it is given. When control leaves the scope in which the lock_guard object was created, the lock_guard is destructed and the mutex is released.
 
Xeo
@EtiennedeMartel I don't see the fun in being drunk, tbh.
 
@AndyProwl I have never observed the lock_guard to start deleteing the mutex.
 
@райтфолд I think you mean Go's defer :D
 
@Xeo But you never were drunk.
 
user1804599
monadic parsing ftw
 
user1804599
9:48 PM
@BenjaminGruenbaum No, that's function-based instead of scope-based.
 
Xeo
And all the times I've seen, for example, Robot or Cat drunk in here don't make me wanna get wasted.
 
I can argue about that but I see the point.
 
@Puppy It unlocks it. By doing so, it gives up the ownership acquired by locking it on construction.
 
user1804599
And can only call functions, not execute arbitrary statements, so you need an IIFE which is fucking retarded.
 
@AndyProwl Giving up ownership is not what happens when you destruct an owning object.
the lock_guard owns ... well it's hard to describe, but it does not own the mutex.
it only owns that particular attempt at locking the mutex.
that is what is destroyed when the lock_guard is destroyed.
the lock_guard does not own the mutex in the slightest.
 
9:50 PM
Yes it does
 
it owns a locking of the mutex.
which is a completely different thing.
 
What happens if it fails to take the mutex? Doesn't it block until it does?
 
That's what people mean when they say owning a mutex.
To own a mutex is to have it locked.
 
that sense of "owning a mutex" is completely different to ownership as regards to C++ object ownership.
 
user1804599
lol leftwing bastion olympic games ripoff in azerbaijan
 
9:50 PM
confusing them is unwise as they are completely different.
 
user1804599
and corrupt fifa worldcup in qatar
 
user1804599
oil magnates really love sports
 
to clarify - holding the mutex = owning the mutex
 
but not in the sense of C++ object ownership.
if you're talking about resource management ownership, that is a totally different thing.
 
why is it completely different?
 
9:52 PM
the fact that they both happen to be named ownership is unfortunate, but irrelevant.
 
It's not the same as object ownership, no. But in my experience when people talk about "Owning" a mutex, they mean having the lock.
 
how is that totally different? new/delete are coupled responsibilities just like lock/unlock
 
@BenjaminGruenbaum Simple example: locking a mutex does not destroy it or arrange any mechanism for it's destruction or freeing.
nor does unlocking the mutex.
you don't do std::lock_guard m(new mutex());.
 
Why does it have to be freed
 
that is mandatory in the C++ ownership model.
 
9:53 PM
@Puppy of course because that doesn't make sense to lock a new mutex
 
@BenjaminGruenbaum Right, because object ownership and mutex locking are totally orthogonal things.
 
@Puppy I see your point about owning the mutex vs owning the lock to the mutex - but I would definitely not call them orthogonal
 
you could express mutex locking as owning a resource, which is that particular attempt to lock the mutex.
 
user1804599
I wonder if men and women are allowed to cheer in the same stadium.
 
but it certainly does not own the mutex itself.
the difference between lock_guard and unique_ptr is that lock_guard creates a fresh resource in the constructor.
 
9:54 PM
@Puppy yes, that's owning a resource. No one here meant "owning the memory the mutex is in" for a second.
 
it's really all about automatic fulfillment of responsibilities. unique pointers fulfill their responsibility on destruction by deleting the object, lock guards fulfill their responsibility on destruction by unlocking the mutex. The owner is the object that fulfills the responsibility.
 
What Andy said
 
@Puppy higher-order programming > RAII
 
@AndyProwl But they're not the same because lock_guards create a new responsibility.
unique_ptr accepts an existing responsibility.
@BartekBanachewicz execute-around is strictly inferior to RAII.
 
@BartekBanachewicz really no
 
9:56 PM
Not this again
 
atomically $ update

vs
{
    Mutex m;
    update();
}
sure, RAII is powerful and all that
but in this case I really prefer the former
 
@BartekBanachewicz In your atomically example - how would a reader be sure that it deterministically takes and releases the mutex? Can the reader always be sure of that.
 
@Puppy Having a responsibility makes you an owner. How you obtained that responsibility, in what form and through which mechanism does not make you a non-owner.
 
the problem with execute-around is when you start wanting to do shit like have a mutex as a member.
 
just my $0.02
 
9:57 PM
@AndyProwl Right, but the mutex itself is not the lock_guard's responsibility.
hence, the lock_guard does not take ownership of any resource.
 
unlocking the mutex is the lock guard's responsibility
 
it creates a new resource.
 
@BenjaminGruenbaum um that's what atomically does?
 
just like deleting the object is the unique pointer's responsibility
 
As someone who implemented this "higher order" stuff for resource handling in several languages several times I'd kill for something as deterministic as RAII often. I even asked a question about it and got an answer from Eric Lippert once.
 
9:58 PM
and that's why it doesn't fit the pattern Benjamin described.
 
@BenjaminGruenbaum you know I've coded in this C++ language once fyi
 
"once"
 
anyway not going to start a discussion
@Rapptz what?
 
@BartekBanachewicz right, but you get an API you did not create and is not in something like Control.Monad.STM you don't really have the same guarantees.
 
user1804599
bartek let's work on compiler
 
9:59 PM
@Puppy unique pointer does not fit that pattern indeed. That does not mean that that pattern is not a pattern of ownership though.
 
@AndyProwl No, I said, the lock_guard doesn't fit the pattern.
 
For all you know it could not even call your your code, or call it twice, or not lock it - you don't have the deterministic guarantee of when control enter and leaves.
 
user1804599
std::unique_ptr is incredibly bad.
 
user1804599
It shouldn't support null pointers.
 
because it does not take a resource, like he described, and then take ownership of it.
it creates a new resource.
 
9:59 PM
@Puppy How does it not? res is the mutex
 

« first day (1601 days earlier)      last day (3362 days later) »