« first day (315 days earlier)      last day (4650 days later) » 
00:00 - 16:0016:00 - 00:00

4:00 PM
Yep, that's the thing.
So, you understand SFINAE after all :)
 
Yes I get it now, but it takes trying to implement it at least once, hahah :)
Thanks for assisting in this :)
 
Note that if you wanted to print things like you did, you could just use a single function and branch with if on the type traits: ideone.com/agPGW.
But if you wanted to call the member functions of the animals, you couldn't use the ifs because they all would need to compile and not all animals have all those functions: ideone.com/Z3Ywi.
Woo, I got another Necromancer badge!
Well, actually you could do it anyway without SFINAE, but that's not my point. And with SFINAE it's more flexible.
 
4:20 PM
sure
now it's time to get the hang of decltype
meh
 
Oh that's easy.
 
from what I get its used to decide the return type of a function for use with perfect forwarding
 
That's a specific use.
It gets you the type of any expression.
 
so int b = 0; decltype(b); is a valid piece of code?
 
Not really, because int b = 0; int; isn't either.
But int b = 0; decltype(b) c = 2; is.
Damn, edited the message instead of posting a new one.
 
4:24 PM
so you can declare a variable with decltype without explicitly saying what type it has to be?
 
Yes.
In a way, you're saying what type it has to be: the same of the expression.
 
I guess that is most useful in template programming?
 
Yes.
Because you don't need to figure out yourself what the type will be. The compiler does it for you.
 
so if you have decltype(T) = Animal::get(); where get returns an Animal type, you'd get T to be a type of Animal?
 
No, you can't do that. You can't assign to types.
decltype(Animal::get()) stupid_function() {
    return Animal::get();
}
But this you could do.
 
4:28 PM
in an application I measure a lot of 2d coordinates (x,y) of a
pattern. This pattern consists of a set of points on grid with fixed
pitches in x and y direction. These coordinates all have a score for
quality and are sorted on this score. What I want to do is to sort
these coordinates first on x and define groups (regions) of
x-coordinates that belong together. After this step I want to sort the
different x-regions in y-regions.

After this I am able to label the coordinates to the corresponding
 
Or you could do typedef decltype(Animal::get()) T;. I guess this is more like what you wanted.
@NicholeGrace Please don't copy and paste your questions here. You could just post a link to it.
0
Q: Sorting Coordinate Points c++

Nichole Gracein an application I measure a lot of 2d coordinates (x,y) of a pattern. This pattern consists of a set of points on grid with fixed pitches in x and y direction. These coordinates all have a score for quality and are sorted on this score. What I want to do is to sort these coordinates first on x ...

 
ok im sory about that ..
 
Even then, drive-by linking to your questions will not get you many friends here.
 
@Mahesh The word you are looking for is "commutative" (a friend b -> b friend a), not "transitive" (a friend b, b friend c -> a friend c).
 
@FredOverflow - Yup. You were on my friends list :)
 
4:33 PM
@Mahesh I am neither a class nor a function.
 
You are the alpha and the omega.
 
class is an entity that can be uniquely identified. I believe everyone is unique by nature. Isn't it ?
 
I am. Even though I'm manufactured, I have a unique serial number.
 
As a developer you want to be as non-polymorphic as possible, so your employer cannot replace you with another implementation.
4
 
@CatPlusPlus - LOL
 
4:39 PM
lol
 
Refuctor often.
 
Quidquid latine dictum sit, altum sonatur.
 
Will "C++ Concurrency in Action" ever be published? :(
On the plus side "Learn You a Haskell for Great Good!" is finally available in dead tree form :)
 
4:53 PM
for(j=0; j<array_len; j+=8)
{
    total += array[j+0 ];
    total += array[j+1 ];
    total += array[j+2 ]; /* Main body of
    total += array[j+3 ]; * loop is unrolled
    total += array[j+4 ]; * for greater speed.
    total += array[j+5 ]; */
    total += array[j+6 ];
    total += array[j+7 ];
}
 
I was about to complain about alignment.
 
This only works if array_len is a multiple of 8.
 
This doesn't really work.
 
@FredOverflow You're missing something more important than that.
 
You commented out the addition of three cases.
 
4:55 PM
Though that one's obvious, especially if you use syntax highlighting, and who the hell doesn't.
 
Well. Some don't.
It's true.
But they deserve what they get.
 
Yeah, some also use proportional fonts, but we don't talk about crazy people.
 
Crazy people are people too!
Hmm, I guess this whole "... are people too" business works better if the things in question are not really people.
 
how to unroll a loop?
 
Like above (minus the nasty comments).
If the size is a multiple of 8.
There's also Duff's device.
You can also use some template magic sometimes.
 
5:01 PM
Or you could just let the compiler do the unrolling.
@CatPlusPlus Bjarne uses proportional fonts.
 
Yeah.
@FredOverflow And you think he's not crazy?
 
He is, but in a good way.
 
WTF I didn't notive three lines of code are commented out
 
That's the point of it.
 
@JohannesSchaublitb That's probably because you never write implementation comments, at least I don't :)
Maybe we need a new 2D syntax for rectangular comments (as opposed to line-oriented)?
 
5:17 PM
@FredOverflow what's a "implementation comment" ?
I write comments everywhere. also inside function bodies
and I always use C style comments. only rarely C++ comments
which perhaps is a bit weird
 
@JohannesSchaublitb It is a comment that is only relevant to the maintainer of the code, not the the user.
 
Does the type of "this" change when being in the scope of base class member function and derived class member function ? I mean any implicit type casting.
 
@FredOverflow ohh
then I write implementation comments too
 
@Mahesh Yes, the static type of this changes. However, it still points to the most-derived object.
 
I think they are important for me to not forget how things are done
 
5:20 PM
I usually break down large functions into smaller functions until the logic is self-evident in the code without comments.
I can't remember the last time I wrote a function with 10 or more lines.
 
And you comment the non-self-evident ones right?
 
I refactor until there are no non-self-evident ones left.
LOL, I just noticed that the Bones DVD I currently have in my DVD ROM is listed as "UNDEFINED" in Windows explorer :)
 
@FredOverflow - So, the run time type of "this" is going to be same. Or type cast is still required at run time too.
Implicit type cast.
 
@Mahesh The "runtime type" is always the same for an object, no matter how you point to it. Dynamic dispatch will always work, no matter if you (statically) point to a Base or to a Derived. That's the whole point of OO, after all.
Do you have a specific piece of code in mind? Then post that.
 
> You are trying to cheat... At Solitaire ? – Nemo 3 mins ago
 
5:24 PM
@FredOverflow - No, I am just thinking of how implicit typecasting of "this" is done by compiler and how it is managed at run time.
 
@FredOverflow Dynamic dispatch doesn't work on base class constructors.
Speaking of which. I want freaking multimethods :(
 
@RMartinhoFernandes Of course not, the derived object does not exist yet.
@Mahesh Usually via something called a "vtable" (google that). But what exactly do you mean with "implicit typecasting"?
 
@FredOverflow - From a derived class member function, if I call a base class member function - how type of "this" is handled.
 
@Mahesh Is that base class member function virtual? Also, do you use single inheritance or multiple inheritance?
Maybe you should buy the book "Inside the C++ object model", it answers all these questions.
 
Just curious. How many C++ books do you own @Fred?
Seems like you have a ton.
 
5:29 PM
@FredOverflow - No, a regular member function. Single inheritance.
 
@RMartinhoFernandes Last time I counted, it was 10. But that does not include "The C++ object model", I'm simply not interested enough in non-portable implementation techniques.
@Mahesh So you don't even have dynamic dispatch. In that case, the this pointer is simply passed on and changes its type quietly to a pointer to Base. This doesn't affect its value, though, because in single inheritance, the Base object and the Derived object start at the same address.
@RMartinhoFernandes I also have a couple of C books, but as it turns out, C is not surprising enough to warrant regular study of these books. They have been collecting dust for a couple of years now.
 
I think I only own one technical book.
 
And what book would that be?
 
C++ Templates: The Complete Guide.
 
@FredOverflow - To be frank, I am a student and cannot manage to buy books. I download pdf's
 
5:34 PM
@Mahesh You should at least have one good C++ book to learn from. It will safe you a lot of pain.
 
@FredOverflow - Correct. But I take print out of chapters one at a time and file them after reading
 
Depending on the number of pages, buying a book can actually be cheaper than self-printing :) Or can you print for free at your university?
 
free at my univ
 
I didn't have the money to use on technical books before (they're freaking expensive), and I could find lots of good books at libraries.
 
I have a friend of mine at printing services and he does help me do that
 
5:37 PM
@Mahesh Just out of curiosity, where do you study?
 
Studying in the USA is quite expensive, isn't it?
 
printing of copy right content is prohibited. But my friend saves me from that
definitely
 
@Mahesh was it hard to obtain a student visa? Or are you a US citizen?
 
It was around $5300 for my first semester.
Now they have raised to $8200
 
5:39 PM
@Mahesh Ouch. It's a couple of hundred Euros in Germany.
 
@TonyTheTiger - Not for me, at least
They are people who were rejected 3 times successively
 
I checked out a place in California to go study and it was like $16k for a year
 
@Mahesh do you know on what grounds?
 
5:41 PM
an object only always has one type
it cannot have more than one type
 
Right, but pointers of different types can point to it polymorphically.
 
double type
 
We were talking about the static type of the this pointer.
 
@TonyTheTiger - What I said is for a semester. It turns out to be $16k even for my univ for a year
 
that's two types :P
 
5:41 PM
yes. if one says "the static type of X is ... and the dynamic type of X is ..." one means that the static type of the expression X is ... and the dynamic type of the expression X is ...
 
@Mahesh still a lot of money
 
sometimes the spec contains confusing wording, IMO. it says for the lvalue to rvalue conversion "If the object denoted is not of type T and or a derived type of T, behavior is undefined."
 
@TonyTheTiger- Rejection might have couple of reasons - Bad academics, family financial condition, potential immigrant
out of which the last one is very imp
 
yea true
 
@TonyTheTiger - So, where are you from ?
 
5:44 PM
Europe
 
this suggests that a base class object does not count as an object. I.e if I point to the base class subobject of an object and do an lvalue to rvalue conversion, then i AM pointing to a Base object. not necessarily to the Derived type object (the address may differ).
 
in multiple inheritance, yes
 
I have friends doing MS in UK. It still costlier than here at US
 
@Mahesh yea I know the UK is expensive, cause I've looked into that too
 
Gotta love this.
23
Q: Why isnt iTunes' shuffle random?

joshhuntThis is a problem that has bugged me for the last 5 years, across multiple devices, operating systems and installs of iTunes and iPods. I have found that the iTunes shuffle feature does not randomly shuffle songs. At all. In fact, I can accurately predict the exact sequence of songs that iTunes ...

Shuffle isn't random. But apparently, that's a feature.
 
5:51 PM
2
Q: Determine priority of a window message

cpxIs there any way to programmatically check the priority of a window messages in its message queue? For example: Some of window messages, WM_PAINT and WM_TIMER are known have the lowest priority and be placed after messages with highest priority. I'm looking for something by which you can confir...

how do you determine the priority of a WM message?
 
Ok guys. Time to leave. Catch u later.
 
@TonyTheTiger I think OP tries to do a stupid thing, and should be stopped.
 
@CatPlusPlus why?
 
Order of the messages is generally undefined.
You should not depend on it in any way.
 
6:05 PM
(Aside from the facts like e.g. WM_CREATE is always first, but that is well-defined by the contract.)
 
ah I see
 
Raymond Chen wrote about applications who depended on WM_PAINT always arriving, when in fact it wasn't a documented behaviour. And then they broke, when implementation changed.
 
Same thing might happen if you depend on e.g. WM_TIMER arriving always after e.g. WM_INPUT.
If it's not documented, then it's not guaranteed.
Even if the implementation happens to work like that at the moment.
 
makes sense
anyone every used Asynchronous Agents Lib
 
6:15 PM
Almost there.
@TonyTheTiger Use %29 instead of the wane.
 
fixed indeed :)
 
Not really.
 
Should be %28blah%29.
You used %29 twice.
 
but how is that interpreted then?
 
6:17 PM
Yours is as )VS.100)
 
Markdown 1 - 0 Tony.
 
@RMartinhoFernandes hahaha
 
0
Q: Dynamically creating std::vector // creating a pointer to a vector

Eric SchmidtI am new so I more than likely missing something key. I am using std::vector to store data from a ReadFile operation. Currently I have a structure called READBUFF that contains a vector of byte. READBUFF is then instantiated via a private type in a class called Reader. class Reader{ public: v...

I couldn't finished reading this.
It's painful.
 
:'( people need to read a book before coming to SO for questions
 
6:32 PM
@TonyTheTiger - unfortunately there's no vote to close option "did you try reading a beginners book?"
2
Fresh from the school of psychic debugging: stackoverflow.com/questions/7216460/what-is-strtol-l-internal
@RMartinhoFernandes - I wonder if that question is by the Eric Schmidt"? ;)
 
I'm still baffled by the 4 giga thing.
How did he get to that conclusion?
 
it looks like he accidentally wrote ~0 somewhere...
Hmm actually perhaps there's some kind of max_size() confusion going on
 
I don't know what compiler he is using but mine gives 4294967295, which is exactly 2^32 - 1.
A 32-bit zigamorph.
 
6:51 PM
~0 is an unsafe way to get *(int*)&(unsigned const&)-1 (all bits one)
 
@awoodland "Closed as 'go away and read a book'."
3
 
7:04 PM
lol, look at the related question list on this question.
 
@Johannes - really? I thought it was the definitive way to get all bits 1
 
@awoodland im sorry I was confused
 
@RMartinhoFernandes someone buy the poor kid a book on either C or C++
 
At first I quickly removed the .
Only then did I notice the new keyword.
 
sbi
7:44 PM
@jalf Actually, AMP isn't restricted to GPGPU.
@CatPlusPlus Is the blood involved in shaving the reason you had to do laundry afterwards?
@JohannesSchaublitb Whenever I am tempted to annotate a piece of code with a comment explaining what it's doing, I rather refactor the code so that it becomes obvious what it's doing. I believe that doing so makes this world a better place.
@JohannesSchaublitb An object can only have one dynamic type, but (through references to it) it can have several static types.
Wow, this is an amazing idea!
 
Wow.
Are you sure it's not just a green piece of paper?
 
sbi
@RMartinhoFernandes No, I'm not. But it would be a great idea independent from how it is implemented.
Oh, this one is a funny commercial!
 
7:59 PM
I have a comment buried in this question that I'd like to come up. Can I get one vote?
Oh wait, I got one already.
 
sbi
@RMartinhoFernandes Two now.
Any comment linking to The Definitive C++ Book Guide and List gets an upvote from me. :)
 
Thanks.
This is nasty: ideone.com/r8kBo
 
sbi
@RMartinhoFernandes ??
 
ugh, what a jerk, two comments above yours
 
I keep forgetting about needing explicit.
 
sbi
8:13 PM
@RMartinhoFernandes That's bad. Unfortunately, this is one where the language has the wrong default. explicit should be implicit, and implicit should be explicit.
 
@sbi no. "an object can have several static types" is not meaningful
 
@sbi Exactly my thoughts.
 
sbi
Another one is const. Everything should be const, except when requested to be var.
 
an object has a type. stop. there is no "it's a XXXy type and a ZZZy type"
 
sbi
And, as with const, you need to get into the habit of always putting explicit in, unless, after thinking, you come to the conclusion you can omit it that one time.
 
8:16 PM
@sbi Yes, and I thought I already had that habit. But I forget I still need it for ctors with more than one parameter at times.
 
sbi
@JohannesSchaublitb Of course no, I said so: "through references". It still feels like it, though.
 
The other day was with a variadic template ctor.
I spent half an hour around it because I forgot I could call the stupid template with one argument.
 
that's like saying "through moving my head down, this guy looks like a watch clock" instead of saying "through moving my head down, I look at this guy's watch clock"
lol
 
@JohannesSchaublitb Poetry.
Or something like it.
 
0
Q: Is there a downside to using -Bsymbolic-functions?

Johannes Schaub - litbI recently discovered the linker option "-Bsymbolic-functions" in GNU ld: -Bsymbolic When creating a shared library, bind references to global symbols to the definition within the shared library, if any. Normally, it is possible for a program linked against a shared library to override t...

 
8:25 PM
@sbi No.
 
sbi
@CatPlusPlus I stopped shaving about a decade ago. I've only been trimming ever since. So much easier.
 
That seems like a good idea.
 
8:49 PM
Gorillas don't shave afaik.
Which leads me to this.
 
sbi
@StackedCrooked I'm a bonobo, remember?
@StackedCrooked This is much better, BTW. (Although it angers me that they put baboons onto that page. Baboons aren't apes!)
 
@StackedCrooked - that was one of the smoothest tangential introductions I've seen
 
sbi
@awoodland You ain't seen nothing yet. Here, anyway.
 
evening all
 
Hi.
@sbi There's no C++ there.
 
sbi
8:58 PM
@RMartinhoFernandes Which explains why you can't find me there. :)
 
And the (kind of) bonobo there does .NET and J2EE.
Ouch.
 
and there was me thinking bonobo was some gnome UI thing
 
sbi
@RMartinhoFernandes Well, I'm a programmer, not an expert on primates, but Mitch looks a lot like a bonobo to my untrained eye. ICBWT. (not that his expertise was any closer to mine.)
 
seems facebook would have been much better matched to yahoo answers than stackoverflow
 
sbi
@awoodland Careful here. This is dangerous and slippery territory you're navigating with such statements.
Wow. I just read that some Swiss banks have set their interest to -0.1%. Yeah, that's right: minus 0.1. That means that, if you give them 1000 for a year, you get back 999. Your money actually earns "more" if you store it under your pillow. Time to go into debt, really. You borrow a million, and pay back 999.000. Seems like a good deal.
 
9:03 PM
@sbi - is that called "short buying" then?
 
@sbi Is that adjusted to inflation or something?
 
sbi
@awoodland I wouldn't know the term if it was German. :(
 
short buying;   // here it is in C++
 
it was a pun on the "short selling" that certain newspapers love to bash. (Borrowing something you think will go down, selling it and then buying it back when it does go down to make a profit before returning them)
 
sbi
@LucDanton It's to weaken their currency, which amassed to much value with the crisis of the Euro and Dollar. The Swiss economy is mostly export-oriented, and if their currency is to strong, they suffer badly.
 
9:07 PM
how does the and operator work between a positive and a negative number ?
int a = 8;
b = a & -a
this gives me 8
where as
int a = 5
b = a & a
this gives me 1
can some one help me with this ?
 
which operator?
 
& operator
sorry in the second case its b = a & -a *
can some one explain me this ?
 
& is bitwise
 
yes
i know that
In more simple terms
8 & -8 gives me 8
where as
5 & -5 gives me 1
 
-8 is ffffff8 (if I counted the fs right)
-5 is fffffffb
 
9:12 PM
so what's been up in here?
 
(as twos complement signed)
0xfffffff8 & 0x00000008 = 0x8
whereas 0xfffffffb & 0x00000005 is 0x1
the "special" behaviour is because of the symmetry for powers of two
 
@awoodland Thanks a lot :)
 
(the pause after "& is bitwise" was whilst I was checking I wasn't being daft)
 
9:33 PM
silence ensues
 
I was trying to decide if it's worth asking a question I'm 90% sure the answer is "it's impossible"
 
This can be applied to so many situations.
 
"I could eat a bowl of alphabet-soup and shit a better argument than that."
LOL :P
 
9:55 PM
0
A: C programming change from int to char (NOT TYPECASTING)

TeaWolfA char won't be able to hold more than a single digit integer, so you probably want a string. One of the basic functions to do that kind of stuff is itoa from stdlib.h: int i = 42; char buffer[ 16 ]; itoa( i, buffer, 10 ); An even better option is available from the Boost Libraries, boost::l...

boost::lexical_cast for a C program is quite inventive
 
10:15 PM
2
A: Should my std::vector contain pointers or structs?

wallykThe "overhead" of a pointer dereference is essentially zero. That is, you would have great difficulty of measuring that versus referencing an object in its place. Beware of early optimization and over-optimization, the root of all programming evil. You should do whichever (pointer or object) m...

"look at the header file <vector> to see how it is implemented on your system. It is likely an array of pointers to dynamically allocated memory chunks, each of which holds one or more objects. "
 
Breaks contiguity guarantee.
 
yup
 
 
1 hour later…
11:21 PM
^ There must be a programming language metaphor in there.
 
whats that :)
 
11:52 PM
It's a picture Ozzy Osbourne and Paris Hilton.
 
00:00 - 16:0016:00 - 00:00

« first day (315 days earlier)      last day (4650 days later) »