« first day (510 days earlier)      last day (4421 days later) » 

12:04 AM
hey, I could have really used first-class arrays that work like that earlier :(
 
Xeo
lol
 
@Xeo Can you do that with the size?
 
Xeo
?
alias<int[3]>{1, 2, 3}?
 
alias<int[/*no size*/]>{1,2,3}
 
Xeo
Sure
The alias is only needed because of grammar rules
the size is still deduced from the initializer
 
12:08 AM
@RMartinhoFernandes That reminds me that due to preexisting practice my alias alias is not using the same convention as others aliases, i.e. it's not Alias.
Would C++11-powered owning ranges benefit from that?
 
right
beddytime for DeadMG
nightages everyone
 
Xeo
Found your problem?
 
no
 
Xeo
Oh, I thought that was a typical "I found the error, seems I'm way too sleepy to write sane code, so good night" good night
#include <iostream>
#include <string>

std::string operator"" _s(char const* s, std::size_t l){
  return {s, l};
}

int main(){
  std::cout << "abc"_s;
}
@RMartinhoFernandes guess which compiler compiles that now :)
 
1:13 AM
can anyone tell me why I cant overload operator= using a friend function. does this have anything to do with the fact that compiler provide to the user-defined type adefault operator= ?
 
Some operators are required by the Standard to be implemented as members (and to clarify, a friend function is a non-member). There's no rhyme or reason for that rule except for operator=: in its case, there's a quote on record from a member of the Standard Committee that "allowing conversions on the left-hand didn't seem useful" (to paraphrase).
 
can you tell me what is the advantage of overloading an operator (+ - * / ) using a friend function over define it as a member-function inside the class ?
 
Conversions on the left-hand side ;)
Another reason is that sometime the operator is part of an 'extended' interface but isn't fundamental, in the sense that it can be implemented strictly in terms of the rest of the interface. Then it helps a bit with code organisation/readability to put it out of the way.
Canonical example for that is addition: define operator+= as a member, and provide operator+ as a non-member that delegates all work to operator+=.
T operator+(T lhs, T const& rhs) { return lhs += rhs; } for instance. No need to be a member in this case.
 
for the conversions on lhs : do you mean like this one ob1=10+ob2;
 
Yes.
 
1:24 AM
but you can do it also using member-function like this ob1=ob2+10;
no ?
 
But that's a burden on the user of the class (to do o + 10 and not 10 + o), not on the implementer of the class. That's a telltale sign of bad design.
 
so there is two advantages : lhs conversions and and code organisation ,
thanks for your help
 
 
1 hour later…
Xeo
2:29 AM
0
Q: Simplification of Template Class Specification

user667967I am very interested in the possibilities of template classes. Now, I am wondering how I can achieve following: Const<5>::getValue(); At the moment I can do this: Const<int, 5>::getValue()); And that's the implementation of the class: template <typename T, T valu...

Close votes please
 
2:41 AM
is there any advantages to overload operator using member-function over friend function excluding (operator= )
@Xeo
 
3:30 AM
@AlexDan I recommend that you read this. There are different levels to the question of whether it is better to overload as a free function or member function. From the design point of view, is the operator an operation performed on the lhs? More that on the `rhs? In many cases they are not. The overloaded operation is a an operation applied equally to the two objects
On the syntactic level, and actually because of exactly the question above, the compiler will be able to perform conversions on either argument because the operation is as much a function of one argument as the other. In the case of a member function the operation is biased towards the lhs, and while in some cases you can reverse the order of the arguments, you cannot always do it
 
Thanks a lot
 
complex = 1 / c; if c overloads operator/ as a member function it won't compile, and as the operation is not symmetric you cannot expect to transform it and get the same result (in a discrete system). Of course you can force the user to explicitly convert the lhs, I the same way that you can force reversing the order of addition.
 
@DavidRodríguezdribeas : do you know other blogs that explain random things on c++ like the way you do in your blog.
 
Going back to addition, is the operation is (in many cases) symmetric in the domain, why would it not be regarding types?
Well... My blog, if I just had time... There are other good blogs out there (mine is suffering a comma... With some luck it will wake some time, but don't expect that to be soon). I don't actively follow any, but I never stop reading and there are some interesting ones
The last Blog I thought I should read is this akrzemi1.wordpress.com/,but there are others more mainstream... Suttermill, articles and videos on channel9, cppnext... In no particular order. And some classics that everyone should have read like GOTW
 
3:47 AM
thanks for the suggestions, I've found too this one stackoverflow.com/questions/151974/…
 
 
3 hours later…
Xeo
7:02 AM
<- European
4
Q: The first string argument to a stringstream is saved as a pointer/garbage

PrisI'm trying to build up a string using stringstream, in the same way you'd use cout. This for something like a logging class. The issue I'm having is that if the first argument to the << operator is a string, when I subsequently print out that stringstream with the stringstream::str() call, ...

Close votes please
 
the mistakes in Modern C++ Design make me sad :(
 
7:57 AM
@kmore which ones? and: Why?
@ScottW shh. I was underway. I can vouch I don't drive while asleep
@ScottW not really. fun. To be honest, I have crashed into the siderail once when I was was (in hindsight) overly tired. Someone before me pulled an impossible overtake right in front of me, and I... reacted late/badly I guess. Just lost control ever so slightly. Skated the highway for about 200 more meters, doing about 280° and landed 'nicely' on the right side curb.
Wew. Not my definition of fun, but I bet it must have looked nice, like 'slow motion'
 
@sehe just grammatical errors, viz. "the worthless ones"
 
@kmore ah. poor you :)
 
8:16 AM
what a waste of time
alias templates can't be specialized, so they can't be used as a way to partially specialize (member) functions
 
@kmore Yeah, you have to create an intermediate struct and have the alias refer to it
 
Xeo
@kmore You could have specializable alias templates, or template argument deduction.
 
@Xeo thanks, after reading through the relevant parts of the standard, it makes more sense
 
Morning all
I see @Dead was having fun last night with DX data structures :P
 
Xeo
"fun"
 
8:29 AM
DeadMG-fun
 
he should know by now that most of the DX 'class' are more or less just old C style structs with 'static functions'
 
How much faster is if(x & foo) compared to doing if(x > bar)? Is it worth doing so?
(assuming foo is a mask that approximates the comparison)
Oh and if @sehe is here, what are those profilers you recommended? (I forgot to write them down!)
 
@Pubby iperf, oprofile and valgrind (cachegrind tool) -- all linux based
 
I would image that the difference would be so small, that unless you are dealing vast amounts of this check, the more readable version is the one to go with
I especially, as I don't see how you can make those both the same
 
@sehe Thanks!
 
8:40 AM
unless you meant (X == bar) rather then (x > bar)
 
foo would be something like 0b11111100 and bar would be 6
foo would work for >4
 
but (x & foo) is a way of doing an equals check
perhaps I need to wake up a bit more first
 
Na, I need >
@sehe Are those good for also profiling multithreading?
 
well, like I said, I don't see how you could use bitwise AND for that
 
@thecoshman You can do it for powers of two, which is a decent approximation
 
8:50 AM
@Pubby what do you mean? I know the fancy pants using bitwise for bolean flags and bit shifts for powers
 
Try (x & ~15) for e.g. [0..32]
 
Xeo
@thecoshman If you mask out the lower bits, you will either get something > 0 if it was > mask, or 0
 
o_0 I don't see it... stupid micro optimisations
 
Xeo
@LucDanton That would be less than, no?
 
@Pubby Yes. Remember to use the amazing KCacheGrind with cachegrind :)
 
8:53 AM
2 mins ago, by Luc Danton
Try (x & ~15) for e.g. [0..32]
Compile the damn stuff.
How else can you be sure? You seem so hesitant.
 
Xeo
Yeah, nvm me
2
 
sbi
@thecoshman Of course. Didn't you know that?
 
@sbi I did indeed, I just saw it and thought you would appreciate. apparently not :(
 
sbi
@thecoshman I certainly had never heard about it. :)
 
9:09 AM
@sbi your just confusing me know :P
 
sbi
@thecoshman You seem easy to confuse. (Claiming to be a gorilla, how could I admit to never have heard about this?)
So @Xeo wants us to not to mind him. I guess this is prompting us to plonk him?
 
this says it all really :P
"cachegrind" sounds like a music style or something, like a type of grind-core
 
sbi
@TonyTheLion The problem is that, no matter what they tell you, nobody knows anything more than that about how great software is created.
 
@sbi yea, I agree, I have found that with the little experience I do have already, that great software is a very hard thing to create.
> I'm going to give up being tidy & organised. From now on everything gets filed under "miscellaneous".
 
@sbi I'm starting to think more and more that we need to settle you down in a home
 
9:18 AM
haha
 
sbi
@thecoshman Currently I'm in someone else's home in London. It's nice here. But I do have a home of my own, which I will reoccupy next week. So never you worry.
 
@sbi oh welcome to London :)
I love that place :)
 
sbi
@TonyTheLion Are you in London currently??
 
@sbi unfortunately not :( I wish I was, so I could come say hai
 
sbi
@TonyTheLion Aw, too bad.
 
9:21 AM
@sbi I'll have to come to Berlin again someday to have a beer :)
 
sbi
@TonyTheLion Oh yeah, do that!
 
@sbi maybe in summer
 
@sbi I am fairly sure you know full well what sort of home I want to put you in :P
 
then I can enjoy some of Berlin too
 
I like the idea of flying some where, getting to a pub, having one pint and then flying home again
 
sbi
9:24 AM
@thecoshman Oh, a bigger one?! That would be great. My apartment gets really crowded when all my kids are there!
 
1
Q: Should you declare enums inside or outside a class?

aCuriaShould you declare enums inside or outside a class if the said enums are only used in the class member functions? namespace nspace { // need to append OC, as this pollutes the current namespace enum OUTSIDE_CLASS {OC_POINTS, OC_LINES, OC_LINE_LOOP, :::}; enum OTHER_ENUM {OE_POINTS}; class Verte...

 
@thecoshman I've done exactly that before
 
^ Interesting with all three current answers, by high-rep users, containing incorrect claims.
 
@sbi ¬_¬ I don't think the imaginary table will stay level much longer
@TonyTheLion :O jelly
 
sbi
@thecoshman Given the price you have to pay for a pint here in London, that might not even be as crazy as it initially seems...
 
9:25 AM
@CheersandhthAlf but they have high rep, they must be true
 
sbi
@thecoshman What's that mean?
 
@sbi ah, but that price is to cover the cost of ferrying half dead drunks to hospital
@sbi get in old folks home, or I will (╯°□°)╯︵ ┻━┻
 
sbi
@thecoshman Given the way you keep throwing around tables here you might end up somewhere else long before my kids park me in an old folks home.
@thecoshman Yeah, I heard that binge drinking is a popular sport in the UK. Surprises me.
 
@sbi sadly, this is all too true
 
@sbi it's kind of scary that binge drinking stuff, I mean some of these kids are fairly young, and at that age the sheer amount of alcohol they consume is very scary
 
9:29 AM
Am I right in thinking that for the most part, you have a much more relaxed attitude to drinking, but non of this "must drink ALL the pints" attitude?
 
sbi
@TonyTheLion "Wo keiner träumt von der Zukunft, wird das Volk wild und wüst." — Stefan Heym (something like: "Where nobody dreams of the future, the people get wild and rough.")
 
@sbi with the little German I do understand, I managed to figure that out before reading the translation :)
 
@TonyTheLion with what little English I do understand, I managed to figure that out
 
sbi
@thecoshman In Germany, the alcohol consumption of teenagers has been decreasing steadily in the last few years. OTOH, there keep being these incidents with a few of them drinking very excessively. IIRC, one of hem died of alcohol poisoning a while ago.
@TonyTheLion I didn't add the translation for your (singular) benefit, but for the rest of the lounge.
 
@sbi oh dear... I see the problem England has. My immediate reaction was, only one, "hah we can do better then that"
 
9:34 AM
@sbi surely
 
sbi
@TonyTheLion Really. You have been trying to play down your ability to understand German, but I think you actually understand it pretty well. You seemed to be able to keep up with a German conversation when you were here, and, although you were reluctant, when pressed you could even reply.
@thecoshman Define "better".
@ScottW And I thought you were gone to eat.
 
@sbi :( more kids dying of alcohol poisoning then Germany
 
sbi
@thecoshman "than" Or do you mean they first die and then go to Germany?
 
didn't think a replay like that would onebox
 
@sbi I guess I I'm not one to easily say that I'm good at something. Probably one of my flaws :(
 
sbi
9:39 AM
@thecoshman An animated gif is a gif, too. (There's even an entry in the newbie hints asking to not to post those oneboxed.)
 
@TonyTheLion I'm not sure if that is a case in point... or not
 
@thecoshman you mean that very statement or the German speaking thing?
 
@sbi I know... that is why as soon as I realised that a something that it would still one box even when a reply I edited it so that it would not be oneboxed
@TonyTheLion that very statement :P
 
sbi
> If I weren't so modest, I'd be unflawed.
@thecoshman I noticed.
 
I was brought up with the idea that saying openly to anyone that you are good at something is "boasting" and that only comes across to others that you have a big ego, which his bad. If I ever said "oh I'm good at blah", then the first reply I'd get is "yea right, stop being so bigheaded"
lol
 
9:44 AM
@TonyTheLion indeed, there is a fine line between being self confident and an annoying twat
 
@thecoshman that is true indeed, and I rarely want to be the latter
right
oh thanks :)
I always knew I was an asshole, just needed someone to say it :P
 
silly groove shark, "down with the sickness" is not by SOAD... but it is a good song
 
by Disturbed it is
haven't listened to SOAD for ages
 
10:00 AM
it is
they where not
interesting fact
shocking news, they are awesome
yah, combo reply!!!
 
2
Q: Boost variant get fail

OckonalI have such code: boost::variant<b2DistanceJointDef, b2FrictionJointDef, b2GearJointDef, b2MouseJointDef, b2PrismaticJointDef, b2PulleyJointDef, b2RevoluteJointDef, b2RopeJointDef, b2WeldJointDef, b2WheelJointDef> prmJointDef; b2DistanceJointDef &prmDistaceJointDef = boo...

I think he might need an explicit cast here
what do you think?
 
Missing header.
 
oh that simple
How does one ever figure out what this code does? looks scary
 
Refactoring. E.g. (*s == ' ') || (*s == '\t') || (*s == ',') happens quite a lot.
 
10:15 AM
hmmm
well, it's definitely not the most readable piece of code imho
 
Given input "foo, +bar+quux baz) +tux" this copies "foo+bar+quux".
Probably.
 
@TonyTheLion looks like simplistic expression parsing. Output will be zero terminated string containing certain stretches of the input. `" \t," are ignored, , then any non-ignored chars are being ouput, but ) and + are being treated as some kind of delimiter
 
right
probably better ways to write in C++ that are more readable
 
it does look scary. Good job security there
 
10:18 AM
lol
I didn't write it
 
Given that's it's a buffer overflow in the making it needs to be changed regardless of the language.
(Well it could be relying on preconditions, that being said.)
 
perhaps, I don't know how it's being used exactly
 
Nul-termination is still dumb.
 
@TonyTheLion Didn't say you did :)
well..... where did you find it?
Usually provides a clue :)
 
@sehe yea true
 
10:29 AM
@ScottW get a pastry
every one loves a pastry
 
this is funny with all the Kony stuff going around :P
 
11:29 AM
lol
I rather find the origami killer than fighting in a war.
 
@LucDanton How about strchr(" \t,", *s)?
 
How about no.
 
It's a lot shorter, and you only have to mention *s once.
 
@ScottW Learn to cook!
:)
or find somebody who does it for you
 
y~?
^ Why not?
 
11:37 AM
I wonder if anyone else from Switzerland (or close to) comes here regularly..
 
Well, I'm from Germany, does that count? :)
Ich begrüße auch alle Zuschauer in Österreich und in der Schweiz!
 
:)
Berlin?
 
Hansestadt Hamburg
 
?
That's on the other side of Germany
 
Well, it's certainly no cat jump from me to Switzerland :)
 
11:43 AM
I would love to join a Longue<C++> meetup if it didn't take me like 10 hours to drive there..
I wonder if the "cat jump" expression is actually used in English.
 
I don't think so :)
> Aalsuppe (Low Saxon Oolsupp) is often mistaken to be German for “eel soup“ (Aal/Ool translated ‘eel’), but the name probably comes from the Low Saxon allns [aˑlns], meaning “all”, “everything and the kitchen sink”, not necessarily eel. Today eel is often included to meet the expectations of unsuspecting diners.
lol
 
ah :)
 
I bet I can throw a stone further than a cat can jump!
certainly not 10s of meters
Was the cat filled with helium?
 
hehe
 
    //------------------------------------------------------------------------------
    // <auto-generated>
    //     This code was generated by a tool.
    //     Runtime Version:2.0.50727.3623
....
^^ Everytime I read this code was generated by a tool I know they were trying to hide the name of the particular tool coworker :)
 
11:56 AM
@sehe If only there were some way to patch all the "tools" around office
I had the misfortune of having a tool for a boss , who thought the best way to count up from 11 was :
for (i =0 to NUM)
{if i>10
// do some shit
}
 
@angryInsomniac interesting code snippet language
@ScottW @angryInsomniac It seems I struck a chord :)
 
I have the choice between Qt and moc or MFC
 
@sehe Real production level code written by my superior :) and then he asked me to optimize my code :D
 
12:00 PM
By the way, to who starred it: i think it would word better to star the followup message chat.stackoverflow.com/transcript/message/2885967#2885967
 
@angryInsomniac wow! it takes a special type of person
 
@sehe It played a whole harp :)
 
Well I have to agree "The Microsoft Foundation Classes (MFC) are a nightmarish mess. I'll say it again - the MFC is a programmer's nightmare. At one point it almost inspired me to give up programming and take up something less irritating.."
 
@thecoshman If only such "special" people could be institutionalized and kept as far away from a keyboard as possible ! :)
 
@angryInsomniac Meh. Symphony orchestras routinely employ two harps. And a piano. That's aside from string, woodwind, brass and percussion sections (did I miss much? Oh noes, not the choir)
 
12:02 PM
@sehe The choir choked themselves to death when they saw that snippet :)
 
@ScottW <-- percussion section
COW ORKER
 
haha
 
@sehe :D
 
so back to work
have a nice weekend!
 
not yet, not until midnight
 
12:20 PM
what's the difference between stderrr and stdout ?
 
First one is intended for error output.
 
@TonyTheLion Different output streams may be connected. Also, stdout is linebuffered, whereas stderr not necessarily
@TonyTheLion Perhaps you mean the 'confusion' that usually, both are connected to the terminal output?
 
@sehe yea
in the end of the day whether you write an error to stdout or stderr, in most cases it both ends up on the screen, so it makes no difference
 
That's a property of the implementation btw, not of stdout or stderr.
Speaking of implementations, I can easily triage outputs here: foo 2>errors will not display errors 'on the screen'.
 
ah right
makes sense
 
12:25 PM
(I hope I got that syntax right, I usually have to give it a go or two.)
 
@TonyTheLion What are you doing here, did someone mention sex?
 
@LucDanton it's ok, assuming POSIX-ly shells
@FredOverflow You did
 
hi :)
 
@FredOverflow not that I know of
 
@KonradRudolph ohai
 
12:30 PM
Yesterday I learned about linux file permissions, you know, 777 means anybody can do anything.
 
And then I thought about the number of the beast, 666 :)
Nobody can execute it, that's really evil :)
 
@sehe What works everywhere I've tried it: somecommand > somefile 2>&1 redirects all/"stdout+stderr" output on Windows and Bash shells.
 
@ScottW great lyrics, also:
I am the thunder of love and pain
My heterosexual weapon will drive you insane
My semen is made of hellfire
To have it inside of you is your biggest desire
Women of all ages and races
Are begging to be my love slaves
Sex machine
Iron man
I am the horniest motherfucker on earth!
 
12:34 PM
> My semen is made of hellfire
lol :P
 
sounds like a really bad infection
 
why c++ doesn't pass by reference as default and by value as option?
 
because that's not how the language was designed
 
because historically, references were introduced after, well, "nothing" :)
Also, why would passing by reference make more sense as a default? It doesn't.
 
& key is consumed on my keyboard
 
12:35 PM
You can use bitand as an alternative.
 
@FredOverflow You will go to hell for this
 
cpx
@FredOverflow metal band?
 
"hungry" describes the condition where one craves intake of more food. what is the English name for the condition where one needs to expel the end result?
 
@FredOverflow Because that's 01232 in octal right? :)
 
cpx
12:37 PM
I'm wondering if there's a book for understanding the fundamentals of metal music. like growling, screaming etc.
 
(off to lunch)
 
Please dont murder me for this , but does anyone here know jxl ?
 
<grabs rifle>
 
@cpx Doesn't have a lot of information in and of itself but works as a quick tour of the metal soundscape, so to speak.
 
@LucDanton I already interpreted 666 as being octal for the joke's sake.
 
12:39 PM
@rubenvb Wont help .. i took adequate amount of cover before I braved that question :D
 
@FredOverflow But what's special about 438? :(
 
@cpx There's an introductory video for the different genres of Metal:
 
<clarifies that he is grabbing is experimental rail gun when he said "grabs rifle">
 
@LucDanton Again, 666 octal, not 666 decimal.
 
@FredOverflow Yeah. What of it?
 
12:40 PM
@rubenvb Results of your experiment : Fail ! :D
 
@LucDanton It means anybody can read and write, but nobody can execute.
 
@FredOverflow My counter-'joke' was that 0666 is not in fact the number of the beast.
 
@angryInsomniac I haven't even fired yet. And be experimental, I meant working prototype.
 
@rubenvb Oh the qualifiers :D
 
@LucDanton enough jokes about 666
 
12:44 PM
If 666 is the number of evil then 25.8069758 is the root of all evil :D (I had to go there)
 
Some chinese miracle dude is working on getting Cyanogenmod 9 on HTC Legend. OH yeah!
 
supposedly, from what I"m reading, Unix system call's are invoked by using an interrupt, but are windows "system calls" also invoked through interrupts?
 
@angryInsomniac We already went there some time ago.
@TonyTheLion What is a windows system call?
 
@FredOverflow :P must have missed that :)
 
@FredOverflow a call into the kernel, like "ReadFile" would do, so it can access the filesystem
 
12:50 PM
And by interrupts, do you mean something like int 21h in DOS?
 
In computing, an interrupt is an asynchronous signal indicating the need for attention or a synchronous event in software indicating the need for a change in execution. A hardware interrupt causes the processor to save its state of execution and begin execution of an interrupt handler. Software interrupts are usually implemented as instructions in the instruction set, which cause a context switch to an interrupt handler similar to a hardware interrupt. Interrupts are a commonly used technique for computer multitasking, especially in real-time computing. Such a system is said to be in...
like the software interrupt
 
@FredOverflow that video is so genious
 
I guess int 21h is a good example yes
 

« first day (510 days earlier)      last day (4421 days later) »