« first day (839 days earlier)      last day (4109 days later) » 

9:00 AM
Is there UB here?
It's not changing the same variable in one expression/statement
 
Xeo
@TonyTheLion It is.
 
Unless I'm forgetting something about the ternary operator.
 
Xeo
There's no sequence point / sequencing in there.
 
but macros
0
Q: whats the output?

user1677597What will be the output for the following: #include <stdio.h> #define MAN(x,y) ((x) < (y))?(x):(y) main() { int i=10,j=5,k=0; k= MAN(i++,++j); printf("%d %d %d" ,i,j,k); } Here i thought that MAN(10,6) will be called and the output will be: 11 6 6 However the output i...

are you saying the answers are wrong here then?
 
Screw it. I'll consult the standard.
 
Xeo
9:04 AM
@TonyTheLion Yes
 
What a good idea.
@Xeo heh
 
Xeo
@Juhana: It is very related, you're modifying j twice. — Xeo 29 secs ago
 
Oh
The first operand is evaluated; there is a sequence point between its evaluation and the
evaluation of the second or third operand (whichever is evaluated). The second operand
is evaluated only if the first compares unequal to 0; the third operand is evaluated only if
the first compares equal to 0; the result is the value of the second or third operand
(whichever is evaluated), converted to the type described below.
110)
 
Xeo
@chris Wtf
 
ikr
 
9:06 AM
What a Terrible Feature.
 
Xeo
Lemme check for C++11
 
C++11 fixed this.
It's a sequence point issue.
Didn't it?
 
Xeo
@chris Which paragraph is that?
 
That's from C11.
 
Xeo
lol, C
 
9:10 AM
The question was in C, so I used it.
 
Xeo
Oh
I didn't notice that.
 
My version might be a bit out of date, though. April 2011 :p
 
Xeo
> Every value computation and side effect associated with the first expression is sequenced before every value computation and side effect associated with the second or third expression.
Damn, C++11 has it too.
 
Now there's two extra close votes sitting there.
I can't help but feel I'm partially responsible lol
 
Xeo
lol
 
9:13 AM
I was too busy contemplating whether there was a sequence point or not to vote until I found it.
 
so the answers weren't wrong after all then?
 
@chris because the API doesn't allow it : cplusplus.com/reference/functional/mem_funOffirmo 2 mins ago
this example leaks memory doesn't it? ?_?
 
Bye all.
 
> simple functions pointers
lol
 
@Rapptz, Why are there even pointers in there at all?
 
9:15 AM
> cplusplus.com
 
donno, cause noobs have pointer obsessions
 
Xeo
@Rapptz Fuck cplusplus.com
 
Oh, never mind. length needs the pointer.
 
user142019
Let’s DoS cplusplus.com!
 
room topic changed to Lounge<C++>: We don't like pointers. [c++] [c++11] [c++-faq] [get-out] [no-pointers] [no-questions] [no-singletons] [no-topic]
found another tag to add to the tagline
 
9:16 AM
@chris The examples on cppreference don't use pointers
 
user142019
I like pointers.
 
@Zoidberg Kill it with FIRE!
@Zoidberg you suck
 
user142019
Pointers have their uses.
 
@Zoidberg I like pointers too
 
oh gawd :(
what have I done
 
9:17 AM
I hate memory management
@TonyTheLion Good morning
 
@Rapptz, I suppose they figured both cleaning up and RAII would get in the way of the example.
 
@sehe yes, it being Friday, this is a good morning
 
Wait
Is it mem_fn or mem_fun?
 
user142019
The Zoidlang source code is full of pointers.
 
user142019
Because GC. :P
 
9:18 AM
@Rapptz, The former.
 
So cplusplus.com is wrong?
 
user142019
Yes.
 
lol
 
it's terrible
 
I thought it was supposed to be better now
 
9:19 AM
@Zoidberg That doesn't actually make sense. You could use shared_ptr/weak_ptr exclusively. It's just that it would not be easy to make it perform well
 
user142019
It’s full of mistakes and the tutorial teaches C++ style from fifty centuries ago.
 
@Rapptz that's a well known fact. for years now
 
user142019
@sehe cycles make everything fucked-up.
 
@Zoidberg that's why.
 
@sehe robot told me it doesn't suck as much though :(
 
9:20 AM
@Rapptz cppreference.com is also more than occasionally wrong but since it’s a wiki you can just correct the mistakes painlessly
 
@Rapptz, Oh, I found in the C++11 draft that mem_fun is deprecated, but exists.
 
@KonradRudolph Which is why the wiki format is lovely :)
 
’xactly
 
Also a tidbit according to the talk page is that it doesn't get much vandalism.
 
user142019
Wikitext is worse than PostScript.
 
9:22 AM
Wikitext was one of the first markup languages I learned.
 
@KonradRudolph, what's Cambridge like to live in? Do you like it? I'm wondering if, on my job hunt, I should consider it...
 
After using markdown though it sure is bad :/
 
@TonyTheLion I think Cambridge is pretty awesome
it’s small and rural though
 
and it’s raining quite a lot
but still
 
9:23 AM
yes, well rain here too
is there a lot of pubs and stuff?
 
user142019
Wikitext is imparsibru!
2
 
lol
I'm not sure I get the point of enum class
 
yes, they’re f’ing useless
 
@TonyTheLion, The same thing as enums in a namespace, but that you can't implicitly convert.
 
hmmm
man, some people type like they're killing a keyboard
how hard do you have to hit it...
 
9:29 AM
Honestly, I would find some relief in an enum flags, but there are a few things built in that sort of do that.
 
The sad thing is that enum classes don’t offer anything that cannot be achieved – albeit with more code – via conventional C++
 
The thing that would have made the strong typing of enum class useful is flags operations.
You don't need those to implicitly convert to numbers if you have the operators you use with flags defined.
 
user142019
@TonyTheLion strong typing ftw
 
user142019
lol, use boost variant instead of enums
 
user142019
struct male {};
struct female {};
struct other {};
using gender = boost::variant<male, female, other>;
 
9:35 AM
heh
 
@Zoidberg, Even better, using gender = boost::variant<struct male, struct female, struct other>;
I think that would work the same way as - let me find it.
 
142
A: Polymorphism vs Overriding vs Overloading

Chris CudmoreThe clearest way to express polymorphism is via an abstract base class (0r interface) public abstract class Human { ... public abstract void goPee(); } This class is abstract because the goPee() method is not definable for Humans. It is only definable for the subclasses Male and Female....

 
user142019
Algebraic data types pwn.
 
@Zoidberg, It was something like:

template<typename RealClass>
struct Shared {int member;};
using DistinctType1 = Shared<struct DummyType1>;
using DistinctType2 = Shared<struct DummyType2>;
Someone really appreciated it when they learned you didn't have to define a separate structure for each.
And it wasn't me who suggested the better way.
 
9:41 AM
> Not OO enough. Needs an object hierarchy based on an AbstractPissingStrategy and a proper PissReceptableFactory.
 
@chris Are you referring to my answer from the other day?
98
A: How to define different types for the same class in C++

Konrad RudolphA common technique is to have a class template where the template argument simply serves as a unique token (“tag”) to make it a unique type: template <typename Tag> class Fruit { int p; public: Fruit(int p) : p(p) { } int price() const { return p; } }; using Apple = Fruit<s...

 
user142019
@FredOverflow lol
 
If so, it was @Xeo who suggested the shortcut
 
@KonradRudolph, That was exactly what I was thinking of, thanks.
 
0
Q: MFC Project gives me many errors

EXTRAMI'm using VS2010 on Windows XP. If I create project on MFC, and after it's creating, i debug this, i have a lots of errors.

 
9:45 AM
@LuchianGrigore nice...
 
I made use of that to have a Point and a Size, both being distinct types, but sharing quite a few details. Couldn't have done it that easily without you :)
 
damn, he edited
 
damn...
 
well, not like it's any more useful now
 
Please help me. P.S. If i paste this in code, SO gives me error.
I didn't even notice that part before.
 
9:49 AM
user image
5
today's xkcd is so true :P
 
Two people need to click on @KonradRudolph's link and hit the up arrow.
 
Xeo
@KonradRudolph Woah, when did that get so many upvotes?
 
I don't know, but I found it to be a very useful question and answer.
 
@Xeo A bit of multicollider followed by the Tuesday newsletter.
 
@chris ^^ I agree
 
Xeo
9:51 AM
Oh wow.
 
If it weren't for me, it would've been past 100 by now.
 
@Xeo Actually most of them I got pretty quickly (within hours) after posting the answer, and then a steady stream of upvotes over the next few days
 
Since it was in the same newsletter as the Pi question (which bumped it down a slot).
 
user142019
@thecoshman meh.
 
user142019
# tar xvzf foo.tar.gz
 
user142019
9:55 AM
# tar --help also works.
 
@Zoidberg: You live in GNU/Linux world, right? The z is not valid with some older non-GNU tars.
 
user142019
I live in Linux world and OS X world and I hate GNU.
 
user142019
BSD pwnz.
 
man my right foot is rather painful today :(
 
10:13 AM
tar axf
Also who cares about older non-GNU tars really
 
@CatPlusPlus: The abomb does care!
 
user142019
 
That xkcd is dumb
 
user142019
This game was fucking awesome.
 
10:16 AM
Because tar flags are nothing next to find
 
I hate tar flags
 
user142019
Tar should be untar and it should just work no matter what. :P
 
user142019
$ untar foo.tar.bz2 # should just work
$ untar foo.tar.gz # should just work
$ untar foo.tar # should just work
 
I have never bothered to look up what these flags mean
 
user142019
Me neither.
 
10:18 AM
@Zoidberg that's not the unix philosophy!
 
user142019
Why not?
 
user142019
It untars TARs; it does one thing and does it well.
 
user142019
I don’t care about the format of the file. The program can figure that out for me.
 
alias untar='tar axf'
Hint: it does
 
user142019
Oh cool.
 
user142019
10:23 AM
GUI: Good UI Impossible.
 
The Unix philosophy is a set of cultural norms and philosophical approaches to developing software based on the experience of leading developers of the Unix operating system. McIlroy: A Quarter Century of Unix Doug McIlroy, then head of the Bell Labs CSRC and contributor to Unix pipes, summarised Unix philosophy as follows: This is often abridged to 'write programs that do one thing and do it well'. Eric Raymond Eric S. Raymond, in his book The Art of Unix Programming, summarizes the Unix philosophy as the widely-used KISS Principle of "Keep it Simple, Stupid." He also provides a seri...
oh look, a puppy!
 
oh hi
 
Hmm, does ADL also find ns::f when I pass an argument of type something<ns::x> to f?
I.e. does the following work?
std::vector<ns::x> v;
f(v); // calls ns::f
 
For some reason I seem to recall that ADL doesn't take into account template parameters
but I may be horribly wrong
 
@KonradRudolph Unlikely
 
10:35 AM
Trick question.
GCC accepts it
 
user142019
ADL, like most parts of the C++ language, is designed to confuse people.
 
but I think GCC is ’rong
(clang also accepts it)
 
user142019
Try MSVC. :}
 
seriously, who cares about MSVC? I don’t, my code doesn’t compile there anyway
but FWIW, MSVC also accepts it :/
 
user142019
lol
 
user142019
10:38 AM
ICC?
 
@TonyTheLion I think it does.
I recall seeing a proposal by Herb Sutter to eliminate that.
 
hmmm
as I said, I may be wrong
 
user142019
Wait.
 
user142019
ADL doesn’t take into account template params?
 
and if Clang, MSVC and GCC all agree
 
user142019
10:39 AM
Why not dafuq.
 
@Zoidberg It does.
Clang, MSVC, and GCC all agree with me that it does.
 
user142019
Ohh. :P
 
Hmm
Maybe I’m just confused then but I was really surprised to see my code compile after I’d forgotten to qualify a name
 
Xeo
@TonyTheLion It does
 
10:40 AM
the ADL lookup set is "Every fucking thing ever that might even vaguely go near ALL THE ARGUMENTS, ever."
 
pretty much the only things it can't find are members.
 
user142019
I want LDA.
 
You know you're doing something terribly wrong if you're forced to write html for IE6 on your birthday... :|
 
user142019
Arguments that depend on the way the function is looked up. :D
 
10:42 AM
LSD dependent arguments
 
@jalf oh your bday today?
 
@jalf Subtle
Happy birthday penguin
 
also, who the fuck still uses IE6???
 
heh, thanks
 
Xeo
@jalf "Happy Birthday, motherfucker!" ?
 
10:43 AM
Happy Birthday @jalf!!
 
Xeo
(The sentence from whoever forces you to write that html.)
 
@TonyTheLion some of our customers do. So I need to make sure our "please install chromeframe now so we don't have to deal with your ancient browser" page works in IE6
 
Xeo
@TonyTheLion > Furthermore, if T is a class template specialization, its associated namespaces and classes also include: the namespaces and classes associated with the types of the template arguments provided for template type parameters (excluding template template parameters);
 
ah right
 
So I guess it could have been a lot worse
 
10:44 AM
> A Monad n is a free Monad for f if every monad homomorphism from n to another monad m is equivalent to a natural transformation from f to m.
 
the fuck?
 
See how many words you can understand
 
I don't know what homorphism and natural transformation are
and a free Monad is also unclear
but that's what is being defined here
so meh
 
10:56 AM
3
A: Passing std::unique_ptr to helper function

billzProper way is to pass reference of std::unique_ptr to helperFunc: void helperFunc(const std::unique_ptr<MyClass>& ptr) Pass raw pointer my cause dangling pointer which should be avoided, also std::unique_ptr are movable but not copyable, and you don't want to transfer the pointer own...

ARAHGFKJHSGERh.
 
How I missed Android development
All those wonderful spurious class loader errors
 
public void onCreate(Bundle b){super.onCreate(b);}?
 
hm, Mega has an “interesting” approach to pirated content
just delete anything that’s linked anywhere in the web
in other words I cannot share my private, self-authored works via mega
 
lol
so it removes anything that's linked anywhere on the web?
 
@R.MartinhoFernandes @DeadMG I read from "Overview of the New C++" that pass ref of unique_ptr is a good way, I need to look up again, maybe I mistook it
 
11:02 AM
I am planning to e-mail Scott about that advice. He and Herb are wrong.
5
 
agreed.
 
There is close to no reason to pass smart pointers by reference.
 
you have my sword!
 
It should obviously be unique_ptr_wrapper
 
@TonyTheLion Apparently
 
11:03 AM
huh, weird
 
And there is even less reason to pass them by const& than by &.
 
I'm not sure what the reason is for that?
 
Man, ownership is hard :p
you actually have to think
it’s probably going to be some time before comprehensive guidelines have crystallised and made their way through the C++ community
 
why don't you pass smart ptrs by ref or const ref?
 
ah, not really
 
11:04 AM
move semantics??
 
unique ownership can actually handle virtually every situation, IME.
if your ownership is a tree, then you can use unique_ptr; if it's a DAG, you need shared_ptr; if it's not a DAG you need to roll a custom GC.
 
@billz The basic point is that if you don't care about ownership, there is no reason to force some ownership model on callers. You function cannot be called with something from a shared_ptr, or any other smart pointer, or just an automatic variable. For no reason.
 
@DeadMG If it’s a DAG you can probably get away with raw pointers and by-value ownership in many situations
and in a cyclic graph you need to break circularity anyway – ownership is never circular
 
@R.MartinhoFernandes yeah, I get it, thanks mate
 
And there is no more or less danger of dangling stuff with *, &, unique_ptr&, shared_ptr& or whatever.
As soon as you are not taking stuff by value you can make dangling stuff.
 
11:08 AM
for @KonradRudolph 's sample code, should pass by const ref?
 
@billz OP didn’t so I didn’t. Depends on what helperFunc does, really
 
@billz The constness or not of the ref doesn't really matter in this discussion.
having or not const doesn't change anything about the choice of parameters and why you might choose to do it that awy
 
@amirmonshi That's not a cast. It's just a polymorphic reference to the same object (the same object identity in OO speak) — sehe 6 mins ago
 
huh
just realized that I have a strange habit of using my mouse hand thumb to push the numpad enter
 
^ anyone care to lend my statement some more precision? I'm not big on standards legalese
 
11:09 AM
FWIW, the unique_ptr equivalent of MyClass const& is unique_ptr<MyClass const>.
 
Everyone does that, right?
(I mean, _even_ when mousing)
 
mousing <--- that's a word?
 
It is. Because I twote it the other day
Oh wait...
 
it is a word, but I don't think it means what you think it means
 
@TonyTheLion It means exactly what I think it means!
 
11:11 AM
@sehe You'd need to refer to the overload resolution rules, but it does indeed not actually count as a cast.
 
@TonyTheLion "When I use a word," Humpty Dumpty said, in rather a scornful tone, "it means just what I choose it to mean—neither more nor less."
 
@sehe you're just saying that...
 
@DeadMG I'm too lazy to argue about that on SO :)
 
@R.MartinhoFernandes lol
 
user142019
Hello friends.
 
11:12 AM
Hello fiend.
 
is it just me
 
user142019
No, others are also my friend.
 
or "How to submit a proposal?" only covers library proposals?
 
Well, that's what they are really pushing for...
 
hm
 
11:14 AM
I think this "pass smart pointers by ref" came about from people asking the wrong question. If you think about it, "How do I pass a smart pointer?" is an XY question, is it not?
 
Huh. I have received an email and I genuinely cannot tell whether it’s a phishing attempt or real
 
@R.MartinhoFernandes @KonradRudolph updated, still bad answer? help review plz :D
 
@KonradRudolph What's it about
 
user142019
@CatPlusPlus Viagra.
 
@billz Voting updated :) Fix your typo, though. s/pas/pass/
 
11:15 AM
@CatPlusPlus Facebook update of something called “Algorithmic Trading Careers” – the thing itself is spammy, but I cannot tell whether the mail is from Facebook or not
 
@R.MartinhoFernandes I read that advice somewhere, because supposedly, IIRC, it's expensive to pass a shared_ptr by value.
 
@KonradRudolph Check the headers
 
pfft, mostly copy from @KonradRudolph. Thanks guys, always good to learn from top guys, got my knowledge reviewed :)
 
@CatPlusPlus I did
 
@TonyTheLion You gotta do what you gotta do.
 
11:16 AM
@KonradRudolph And?
 
@TonyTheLion It is somewhat expensive.
 
Xeo
@TonyTheLion Yeah, but the XY part is - why do you even pass a shared_ptr? If you want to take ownership, there is no overhead.
 
… I can’t tell.
 
but either you have to share ownership, or you don't, and neither of those situations calls for a const shared_ptr&.
 
it looks genuine but I cannot explain why Facebook would send me such an email
 
11:17 AM
@KonradRudolph What's the origin, does it pass SPF and DKIM verification
 
user142019
@KonradRudolph It’s from Facebook so it’s spam by definition.
 
user142019
@KonradRudolph Email Facebook support?
 
@Xeo hmmm. I'm not entirely sure I understand what you're saying.
 
@TonyTheLion "How do I pass a shared_ptr?" is the wrong question.
 
Xeo
I'd explain better, but I have some shit to fix here. :(
 
11:18 AM
ok
 
That's why the answers don't make sense.
 
@R.MartinhoFernandes ah
 
@CatPlusPlus I don’t know how to tell that, TBH. It has a DKIM header but that’s all I know
sorry, gotta run
 
code base here passes shared_ptr's all over
 
You need to ask yourself what you really want and it isn't "how to pass a shared_ptr".
 
11:18 AM
It should have stuff like
Received: from mx-out.facebook.com (outmail020.snc4.facebook.com. [66.220.144.154])
Received-SPF: pass (google.com: domain of ...@facebookmail.com designates 66.220.144.154 as permitted sender) client-ip=66.220.144.154;
Authentication-Results: mx.google.com;
spf=pass (google.com: domain of ...@facebookmail.com designates 66.220.144.154 as permitted sender) smtp.mail=...@facebookmail.com;
dkim=pass header.i=@facebookmail.com
 
user142019
Email is bad.
 
user142019
It consists of a gazillion bad protocols.
 
Yeah, like, one
 
TIL gazillion == 1.
 
user142019
POP, SMTP, IMAP and probably more shit.
 
11:22 AM
No, mail is SMTP
POP3/IMAP are for mail retrieval and are largely unrelated
> The above links are definitely not worthless. They contain neccessary information for character code and glyph index mapping. Please check out 1st link. It will definitely help...I am extremely sorry I have no experience working with InDesign Api.All the best! – rohank 1 hour ago
Ahahaha
 
user142019
lolwat
 
@R.MartinhoFernandes true, for large enough values of one :P
 
user142019
brb; interview
 
hmmmm
std::hash and std::unicode::hash?
unnecessary confusion?
 
11:28 AM
Why make a different type?
 
Why different
 
because basic_string already has a hash, it's just not a Unicode-compliant hash.
 
Unless the latter is a function that operates on ranges or something, used to build custom hashers.
1669: Hennig Brand attempts to make gold by storing 60 buckets of his own urine in his house for a month, then boiling it for 24 hours.
 
so if you already have something like unordered_map<string, int>, then you can drop in unicode::hash to upgrade your existing code.
 
Man, people were sooooo fucking stupid.
 
11:30 AM
lol
 
although arguably, the compatibility stance of encoded_string is so permissible that there's no reason not to just replace it with encoded_string.
 
That sentence makes no sense.
Why would you replace encoded_string with encoded_string?
 
not std::unordered_map<std::unicode::string, std::unordered_map<std::string.
should have qualified it :(
but you're right, a range version would be a smarter choice.
so now all I need to do is define case-insensitive collation, equivalence, and hashing.
 
You know, I realised I am not actually using the name ogonek::text, so I'm going to rename ogonek::basic_text.
 
lol
 
11:39 AM
This is an unannounced breaking change without any deprecation in place, and I don't want to care about that yet. This is why I don't want to recommend it to people.
 
fair nuffages
I wonder if I could implement my Unicode proposal on top of Ogonek
it would sure be nice to say that I have an implementation when I attend in Bristol
 
Not everything, since I don't have sentence and line breaking yet, nor collation.
But I think you can build a large portion.
 
hmm
sentence and line breaking is less important, I think, but collation would be kinda important.
 
You could contribute it yourself! wink wink
 
still
heh
having most of it implemented would sure be a boon
and
 
11:45 AM
I don't think the collation algorithm is particularly complex.
It's mostly just looking up collation element values from a table and sorting from there.
 
if the Committee accepts it in Bristol, you wouldn't have to worry about changes anymore, just implement the draft spec.
so
apart from Unicode, I am hoping to submit proposals for hash, bound_function, and I'm going to see if I can add allocators to that list.
 
@R.MartinhoFernandes Booo
 
@CatPlusPlus What? I'm using semver and am on 0.4.2, so fuck off.
 
11:58 AM
hmm
is there a reason to have multiple memory heaps except for unsynchronized access?
 

« first day (839 days earlier)      last day (4109 days later) »