« first day (575 days earlier)      last day (4387 days later) » 

3:00 AM
That or learn C. You know, glass half-full etc.
 
What's wrong with understanding how C's library works?
Much easier than learning C++'s
 
@Pubby: I guess that if you're taking a C++ class, you would be doing something like... I don't know, implementing a C++ library instead of a C library.
 
Yeah, am I too naive to expect a C++ class to teach C++?
 
Kind of like how people in Lounge<C++> are expected to talk about C++
No wait that's a bad analogy
 
Eh, parts of C library is still used in C++ to be worth learning
 
3:03 AM
@Pubby: Sure, if we're talking about the math functions I guess
 
@Insilico There's "Lounge" in "Lounge<C++>".
And, no, I don't want you to tell me that there's "C" in "C++".
@Pubby In C++11, maybe just the math stuff.
 
Yeah, although implementing C++ standard library involves dealing with more C functions I guess
 
Eh?
How come?
 
I dunno
 
@Pubby: Of course some C++ standard library implementations use C functions
Although I could implement the entire library with just straight C++ and a handful of OS-specific API functions and no one would be any the wiser
 
3:07 AM
Yeah, although you wouldn't know how to do that if you didn't understand the C functions
 
Again, how?
It's like saying "you need to know C to learn C++".
 
How can you do anything if you don't understand memcpy?
 
@Pubby What parts of C library?
 
Use std::copy.
 
@Pubby: You don't need to know memcpy to know how to copy bytes from one place to another place
 
3:08 AM
I dunno, whatever @moshe is talking about :D
@Insilico What do you mean? There's not many ways of doing copies.
 
@Pubby I'll say it again: std::copy works, you know.
 
@Pubby: for(int i = 0; i < length; ++i) { dest[i] = src[i]; }?
 
The only thing from C library I use is um... assert, maybe. And atexit. And once, wcstomb because stupid WinAPI conversion function didn't want to work.
 
SSE instructions that copy bytes?
 
@EtiennedeMartel I'm (we're?) talking about implementing C++ library. They wouldn't know how to make std::copy if they don't understand memcpy
 
3:09 AM
Actually assert sucks, I prefer to write my own.
What does implementing C++ library have to do with C?
 
@Pubby They could first implement std::copy with a simple for loop.
 
I dunno, I'm just rambling about nothing, as usual
 
If you're implementing a C++ library then you obviously should know a thing or two about programming.
 
It's like saying "You need to undersand memcpy to know how to use a loop"
 
@EtiennedeMartel Which is more or less the learning the same thing as memcpy
 
3:10 AM
@Insilico That's not C library, that's compiler intrinsics.
 
@CatPlusPlus Reminds me, if you come across a non schizophrenic assert library, plink me.
 
What'd you mean?
 
Anyone attempting to use SSE properly better have pretty damn good understanding of all low-level memory things that C++ tries to hide.
 
I want an assert that the compiler uses to optimize :(
 
@CatPlusPlus Of course. I was trying to demonstrate that there are many ways to copy bytes from one place to another
 
3:11 AM
@Pubby VC++ has __assume.
 
GCC has __builtin_expect or something like that.
@Mysticial On that note, do you have any good introductory-level materials for hardcore SSE?
That sentence is full of contradictions, isn't it.
 
@CatPlusPlus Not really, I literally taught myself by looking at Intel and MSDN's docs.
 
Ahm. I don't think I'm motivated enough to go on trial-and-error way.
 
@CatPlusPlus Good, introductory, or hardcore. Pick one.
 
Well, good.
Also "or".
 
3:13 AM
Basically... write something that works using primitive types.
 
Last time I tried SSE I didn't know what functions to use or how to optimize it, not to mention ending up with an unreadable mess :(
 
Then go look up the list of SSE intrinsics.
Try to apply them to your app.
 
Vectorisation is a bit of paradigm shift.
 
@Mysticial Think you could look at my old SSE code and give a few pointers? (if I can find it that is)
 
Then at some point, you'll realize that your initial design is complete shit because it doesn't work well with vectorization.
Then you redesign and rewrite everything with vectorization in mind.
And viola, now you know how to use SSE.
 
3:15 AM
The real difficult part of SSE is the fact that not all processors support the same set of instructions
 
@Pubby Sure, I can usually spot a lot of common (performance) mistakes.
 
All 64-bit CPUs implement at least SSE2.
 
So you basically write your application twice, one that uses SSE and one that doesn't.
 
If you care about CPUs manufactured before 2004.
(Arbitrary date, don't nitpick.)
 
@CatPlusPlus: Of course, there are lots of functions in newer CPUs that are also useful
 
3:17 AM
@Insilico That's how I initially did it. It took a lot of experience before I figured out good ways to avoid too much code duplication.
 
Although honestly I haven't looked hard enough into that, don't ask me about them
 
Also having two implementations might be good for testing.
If you screw up SSE or something.
 
@CatPlusPlus: Which is of course is 100% guaranteed to happen
 
@CatPlusPlus That gets a little bit tricker when your data representation changes depending on whether or not you vectorize (as well as with varying SIMD sizes).
 
Anything I write that works the first time around is highly suspicious
 
3:18 AM
@Mysticial It's just some matrix math: ideone.com/Sr81Q I wish I had another comment other than "//magic" hehe
 
@Pubby eww... You're using GCC's vector syntax?
 
I guess so, is there an alternative?
 
@Pubby Intel's intrinsics - portable across every major compiler for x86.
 
Cool, I'll use those next time. What's the liscence?
 
@Pubby none
 
3:23 AM
Public domain?
 
They're compiler intrinsics. They're built into the compiler.
That's why we call them intrinsics.
 
But they work on GCC? :S
 
@Pubby GCC, Clang, MSVC, ICC, at the very least.
 
Ok
 
@pubby As for your Mat4Mul function. You look like you're building your r0, r1, r2, r3, vectors one after another. In might be faster to interleave them.
 
3:30 AM
@Mysticial Hm, what would the interleaving do?
 
@Pubby More things to do in parallel.
 
Alright
 
Building each of the r vectors seems to have a long dependency chain.
So if you interleave all 4 of them, you'll get better IPC. It's something you'd think that the compiler will do, but it's an NP-complete optimization problem. So they don't usually find it.
 
Ok, so that's same number of instructions but just rearranged?
 
@Pubby Yeah
 
3:33 AM
That's probably my least favorite aspect of optimization xD
 
0
Q: Which IDE for C++ Do the majority of companies use?

Edwin SohoI'm java, .net developer and would like to start with unmanaged C++ Which IDE for C++ Do the majority of companies use? thanks

 
@EtiennedeMartel Does he just want to fit in or something?
 
@Pubby Yeah, it's messy. Interleaving is particularly rough on readability unless you format the code into blocks with very similar variable names.
 
Hmm, next time I write low level I think I'll try that Knuth comment style
Or at least a comment style. Anything is better than "//magic"
 
We'll need the proof of correctness on paper.
 
3:40 AM
Invoking the proof crashes the compiler
 
Interleaving is also a standard practice for loop unrolling.
@Pubby Here's an example of something that's been unrolled and interleaved.
 
> FreeBSD 10 To Use Clang Compiler, Deprecate GCC
 
#define ymi_CVN_u64b_to_rawh_u2_SSE41(T,A){ \
    register const __m128i _MASK = _mm_set1_epi16(0xf0);    \
    \
    register __m128i _a0,_a1,_a2,_a3;   \
    register __m128i _b0,_b1,_b2,_b3;   \
    \
    _a0 = ((const __m128i*)(A))[0]; \
    _a2 = ((const __m128i*)(A))[1]; \
    _a1 = _mm_shuffle_epi32(_a0,27);    \
    _a3 = _mm_shuffle_epi32(_a2,27);    \
    \
    _a0 = _mm_cvtepu8_epi16(_a0);   \
    _a1 = _mm_cvtepu8_epi16(_a1);   \
    _a2 = _mm_cvtepu8_epi16(_a2);   \
    _a3 = _mm_cvtepu8_epi16(_a3);   \
I basically just append a number to distinguish between iterations.
 
Hm
 
And I group them into blocks so it's very clear.
Each block has exactly one instruction from each of the 4 iterations.
 
3:45 AM
So using same operations after each other is better?
foo; foo; foo; foo; bar; bar; bar; bar; is better than foo; bar; foo; bar; ...?
 
@Pubby Not really - which is the one weakness of this method. But generally as long as adjacent blocks are different, they'll fall into the same re-ordering windows of either the compiler or the processor.
 
Hm, ok
I wonder how much templates could automate unrolling
 
Basically, it's my attempt of achieving both speed and readability.
So in your case, each of your r0, r1, etc can be considered as different iterations of an unrolled loop. So the same tricks apply.
 
Oh, I see
 
Yeah, that's basically how I try to reduce the pain of basic code-duplication.
As for code-duplication from supporting multiple SIMD sizes (no SSE, SSE, AVX, etc...)
that takes some tricks... :)
 
3:58 AM
Give example?
 
They tend to be application specific.
 
Ah
 
But I define my own macros for all the needed operations as well as the data-type itself.
So I'll use something like #define f_vector __m128d
and depending on which header I include, I can switch it between different vector sizes.
 
Cool
 
The code that uses is required to work with all (power-of-two) vector sizes.
Which is where it can get application specific.
Of course this isn't always possible, so some code-duplication is unavoidable. For example, non-vectorized code doesn't need any shuffling.
 
4:10 AM
does a beeping sound usually come from the PC when using dial up? Is this normal?
 
That?
 
Also, TIL: Ye Olde' Village life is a pain in the ass.
 
cpx
I hear a beeping once in a while even though I'm not using dial up
 
@IntermediateHacker You should get this: clayloomis.com/Sounds/simpsongs1/simsg698.wav
 
 
1 hour later…
5:28 AM
how actually we create vector in c++
 
5:40 AM
@HariOm: std::vector</* Your Type Here */> myVector;
Don't forget #include <vector>
 
6:13 AM
Hi all
Has std library check of odd/even numbers? Or I should %2 check?
 
i % 2 == 0
 
Do you really need a library to check if a number is even/odd? That's like "not enough jquery" for 1 + 1 in javascript.
 
Not enough iterators!
 
how would you describe a for loop with colon ":"
like this ..
for ( a1 = 5 : a1 > 0 : a1 = a1 - 1)
what does it even mean??
 
I'm pretty sure you misread semicolons as colons?
 
6:25 AM
no buddy.. it is like that
 
What language is it?
(just checking :P )
 
i guess i am in a c++ lounge ..
google do have some results but not able to describe it properly
 
Where is this from
 
i don't have the source link now
 
#define : ; ?
 
6:30 AM
@Pubby Does that work? I thought macros had to be valid identifiers?
 
IIRC you can do stuff like that in some implementations, doubt it's standard
I somehow used it to play around with custom operators
 
@Mysticial, I don't really need that function. if ( n%2==0 ) is enough. But I though may be it's wrapped in a function in std? why not? if ( even(n) ) is more readable than some % ;)
 
I dunno, n % 2 == 0 seems pretty standard to me.
At least it's more readable than (n & 1) == 0.
 
But n % 2 == 0 can't be passed into functions
 
arg1 % 2 == 0 can.
 
6:37 AM
@LucDanton What's that? Boost trickery?
 
Aye, Boost.Phoenix.
 
I'm surprised that "Not enough Boost" hasn't become a meme yet like "Not enough JQuery". We should start going around and leaving "-1, Not enough Boost" comments under every C++ answer without Boost.
5
 
There's no for that has a form of for (a : b : c).
 
Thanks for looking that up, I guess :p
 
And since it looks like the old one, I'm pretty sure it's ; there.
Whoever was asking.
@Mysticial I second that motion.
 
6:39 AM
Can conditional operator be used in ranged based for?
 
Probably. Still won't be a : b : c.
And for ( a1 = 5 : a1 > 0 : a1 = a1 - 1) either has semicolons, or is invalid.
 
Does this count? for(struct foo{void bar() { a: b: c:; }};;)
(I want to find a solution so I can quiz litb)
 
Can't put a type definition here.
 
@LucDanton In a normal for? You sure?
 
@Pubby No, I'm not sure. Also GCC accepts it.
 
6:44 AM
I've used it to allow multiple variables in init part. I think it's idiomatic.
 
Yuck.
There's nothing idiomatic about that.
 
As long as they're staments....
:p
 
Also old for sucks. Range for ftw.
 
@CatPlusPlus "for ( a1 = 5 : a1 > 0 : a1 = a1 - 1" is valid C/C++.
 
@CatPlusPlus Well then it's idiotmatic
 
6:46 AM
For I in range(12):
 
@Mysticial Eh?
 
So is: // for ( a1 = 5 : a1 > 0 : a1 = a1 - 1
 
#define for(x) while(true) puts("WHOOP WHOOP WHOOP WHOOP WHOOP");
 
@CatPlusPlus You missed the "". :)
 
We're entering litb quizzes territory.
Also for (auto i : boost::irange(0, 12))
 
6:48 AM
A winner is you
 
@Pubby I've checked the grammar and it is allowed.
 
Alright
 
Question, is using a byte instead of an int when you're only looping to, say, 10, "worth it"?
Cba to search atm
 
No.
 
for(auto x : foo <: 0 ]); too. Digraphs for the win!
 
6:52 AM
Express intent, don't use C++ like an assembler (it isn't).
 
kay :)
 
0
Q: Error 2 error C2679: binary '/' : no operator found which takes a right-hand operand of type (or there is no acceptable conversion)

user1391883I have some problem about operator overloading. I looked everywhere but couldn't find a proper solution for this error. Here is some parts of my code : Matrix<type> Matrix<type>::operator/(const Matrix& denom){ if(num_of_rows != denom.num_of_rows || num_of_cols != denom.num_of_c...

That's a good question to post a "-1, not enough Boost." comment. :)
So from this answer:
112
A: Is jQuery always the answer?

paxdiabloThere are two rules to follow if you want to get your answers voted up on SO. 1/ Answer every web question with "jQuery". 2/ Answer every C++ question with "Boost". 3/ Answer every optimisation question with "premature" and "evil" 4/ Learn to count properly. Boom boom, I'm here all week, you...

We can deduce that there should be:
"-1, not enough jQuery"
"-1, not enough Boost"
"-1, optimization is evil"
 
"-potato, not counting properly"
 
Wololo.
 
AEEEOOUUU AEEOOOUUU
 
7:07 AM
wow...
0
Q: About Math.floor(Double.MIN_VALUE)

Zitaminawhy is Math.floor(Double.MIN_VALUE) == 0 ? can any one send me the java algorithme of Floor function or at least explain this result please?

I don't understand how anyone can answer questions like this 15 times a day for 3 years non-stop...
 
8:00 AM
Does anyone know that if you have Visual Studio 2010 Proffesional trail, and purchase a retail copy will the cd key unlock the trail?
 
how do you access elements from a vector..
 
@HariOm vec[index]
 
is that a keyword
 
No
 
so as if we define a vector as : ... vector<int> temp(10);
now we can access 5th element as temp[4]
??
 
8:04 AM
Yes
You can also do temp.at(4) which does range checking
 
oh great.. give me a little hint on range checking
 
temp.at(50); would fail the range check
 
ohk
 
8:17 AM
temp.at(x) throws an exception if x >= temp.size().
temp[x] has undefined behavior if x >= temp.size().
So I played with Blender last day and I came to the conclusion that the UI is horrible.
 
The UI is the keyboard shortcuts
AKA a reasonable and efficient UI
 
Why doesn't blender just have an extensive menu bar with a search function?
That way you can find things quickly if you forgot the keyboard shortcut.
 
The help should be searchable I think
It doesn't make sense to put many of the commands in a menu
 
Many of them require mouse actions, you can only click a menu button
 
8:32 AM
Is Blender written in Python?
 
I think C++ with Python for scripting
 
8:59 AM
GUYS!
 
@RadekdaknokSlupik Yep Blender's UI is kind of yuck, I spawned dozens of panels and had no idea how to kill them =(
Johannes?
 
string temp; temp[0];
is this OK!?
 
no.
temp.c_str()[0] is OK
 
hmm
why is it not OK1?
 
by standard, IIRC
 
It's OK
I think
 
It's okay to get char from string by index
 
Wouldn't the requirement for internal buffer to have \0 make it OK?
 
I will ask a C++ question
 
hm... 21.4.5 basic_string element access [string.access] p1, operator[](size_type pos) Requires: pos <= size()
so it's OK
 
9:04 AM
It's OK but cppr says you can't modify it
> If pos==size(),
The const version returns a reference to the character with value CharT() (the null character). (until C++11)
Both versions returns a reference to the character with value CharT() (the null character). Modifying the null character through non-const reference results in undefined behavior. (since C++11)
 
0
Q: string[length()] in C++, is it OK?

Johannes Schaub - litbMy colleague's code looked like this: void copy(std::string const& s, char *d) { for(int i = 0; i <= s.size(); i++, d++) *d = s[i]; } His application crashes and I think that it is because this accesses s out of range, since the condition should go only up to s.size() - 1. But o...

IMO preview of posts should be live updated
or ... perhaps not
 
WTF is going on with cplusplus.com
 
lol two ppl jumped into giving wrong answers xD
 
@JohannesSchaublitb good trolling
 
@JohannesSchaublitb But why does the program crash?
 
9:12 AM
didn't I say that? I'm an excellent troll
 
we know...
 
I want (troll?) answers!
 
@Pubby i don't know. I will be debugging the program next year
 
Hehe alright
 
What is the final answer, thowgh?
 
9:16 AM
we will see
 
user868935
@anyone What do you think of the new VS11? Is it worth getting or just stay with VS10?
 
@ChocoMan Well I don't think it's worth paying several thousand dollars for
 
@ChocoMan I agree with ChocoMan, I doubt they've made something as good as XCode =)
 
user868935
I think Im gonna stay with VS10. No need to pay again for something that has just been repackaged with minor updates
 
The C++11 updates seem pretty major
 
user868935
9:29 AM
any word on the release date?
 
Good as XCode is pretty low bar.
 
can somebody help me understand this c++ syntax
for( a4 = 0 : a4 < N: a4 = a4+1)
 
It's not valid.
 
 
well.. its the enhanced for loop and completely valid
 
9:38 AM
@Pubby only the library part, the compiler is as broken as ever last time I checked.
 
It's. Not. Valid.
There's no such thing as "enhanced for loop".
There's for loop and there's range for, neither of which look like this.
This is not a valid syntax. Geez. Just try to compile it and see for yourself.
 
@HariOm that's a bad reference.
And your example is messed up.
 
Well, first of all, it's about frickin' Java.
 
Oh yes, I completely missed that :P
 
9:41 AM
bad refrence means what??
 
grabs shotgun
 
And second of all, there's still no loop in that form described there!
 
@CatPlusPlus why would you say a range based for is not a loop?
 
What?
for( a4 = 0 : a4 < N: a4 = a4+1) is not a range for. It's not even a for. It's a syntax error.
As it happens, in both C++ and Java.
 
@CatPlusPlus I was talking about the example in the link he posted.
I thought you meant that with "there".
 
9:43 AM
Where did I say range for is not a loop?
 
2 mins ago, by Cat Plus Plus
And second of all, there's still no loop in that form described there!
 
"That form" being for( a4 = 0 : a4 < N: a4 = a4+1).
 
With "there" I thought you meant cis.upenn.edu/~matuszek/General/JavaSyntax/…
yeah, confuzzlement
You should reply to the right message. It helps other people understand what fuzzy words like "there" mean.
 
Also, in Java, it's called "foreach loop", not "enhanced for loop".
I'm fuzzy.
 
so what is the conclusion.. what does that syntax say
 
9:45 AM
And why are we talking about Java anyway. There's this very useful skill called reading comprehension.
It says "syntax error".
Gawd.
Gotta do something else before I go full crazy.
Possibly sleep.
Sleep might be good.
 
lol
 
Hi, anybody here for whom "strchr" didnt work to find end of line ?
 
@HariOm Are you interested in the semantics of range for for Java or for C++? I can't help with the former.
 
for c++
 
for(foo bar: baz) qux; is more or less the same as auto&& range = baz; for(auto it = begin(range), e = end(range); it != e; ++it) { foo bar = *it; qux }.
Assume that std::begin and std::end are in scope.
 
9:56 AM
are you going away from the point..
can you take up my example
 
What example?
 
for( a1 = 0: a1< N: a1 = a1 + 1)
or this one
 
That's invalid syntax. You've already been told this.
 
ok so as per your briefing...

for(foo bar: baz) qux; is more or less the same as auto&& range = baz;
 
@HariOm replace the : with ; and you get a regular for loop. That's what that should be. Nothing fancy going on here.
 
9:59 AM
hmmmmmmmmmm
 
i'll check my refrences.. thanks
 
Xeo
10:33 AM
@HariOm huh?
 
10:56 AM
Guys I have a basic question: when I'm in a class' destructor can I assume that the object is still alive?
 

« first day (575 days earlier)      last day (4387 days later) »