« first day (961 days earlier)      last day (3984 days later) » 

12:00 AM
Yep, my comment you're referring to was about: is it implemented internally like something like that?
 
I think he was refering to the implementation of swap.
 
It doesn't matter.
std::swap is the primitive to build upon.
 
it does matter for me - I asked what implementation would be internally, just out of curiosity
 
Then know that it conceptually does that, but it can be more clever.
 
Only way to know for sure is look at the headers. Various compilers could choose to do it differently, that's what implementation-specific is.
 
12:09 AM
^, although 'implementation-specific' is a term of art of the Standard where it means something else.
 
In a hypothetical world where the object being swapped is nothing but an internal pointer, then yes a pointer swap like you wrote above might be the right solution.
 
You shouldn't get too familiar with the implementation though. You could shoot yourself in the foot if you assume something that is implementation specific so be careful.
When in doubt, read the standard and see what it guarantees.
 
There could be other things, like swapping the internal string size, buffer capacity.
@Tuntuni Agreed.
Outside scientific curiosity there isn't much use in knowing how it works.
 
Yup.
I like reading MSVC++ implementation lol.
 
Nothin wrong with scientific curiosity though.
 
12:11 AM
It's hella messy though.
Underscores all over the place.
The indendation is out of place.
 
Oh gods blood, those UNDERSCORES
 
Barely readable, but eh ..
Yeah LOL idk who maintains that
 
I always thought to myself, tongue-in-cheekly- that microsoft has some internal copy which actually formats properly. lol.
 
@LucDanton you're working with ranges correct?
 
I always wonder if a part of it is auto-generated somehow but then I also see commends in there.
So .. may god help those who maintain it.
@Kivin Haha.
 
12:12 AM
Surely to goodness, nobody would write their functions like this...

template<class _InIt,
	class _Pr> inline
	_InIt find_if(_InIt _First, _InIt _Last, _Pr _Pred)
	{	// find first satisfying _Pred
	_DEBUG_RANGE(_First, _Last);
	_DEBUG_POINTER(_Pred);
	return (_Rechecked(_First,
		_Find_if(_Unchecked(_First), _Unchecked(_Last), _Pred)));
	}
 
Lawl
look at how the template
 
I had to repair some twenty-five year old C code last week. It was pretty garrish.
 
is broken up
WHYYYY???
 
My wife dug it up on the interwebs. The author abandoned it on some old ass html page with a note "Dunno why it segfaults, but here you go"
 
@Kivin Ouch.
 
12:15 AM
@Kivin Yes they would.
 
It was doing thousands-deep recursion on a machine that probably had like 16KiB of RAM.
@Rapptz I know they do :(
 
That's definitely an implementation of C++.
 
But just look at the indentation. Takes me 15 seconds to find the name of the function.
 
Oh, I know. I was being tongue in cheek.
I think that goes beyond religious wars of where to put your squiggly brackets. It's just purposefully obtuse.
 
Yup.
I do try to respect coding styles but this one is just extreme. I don't know how anyone finds this readable at all. What a mess.
 
12:19 AM
It puts me in the mind of a lot of early '90s C code. None of that stuff has any discernible formatting standards.
 
Heh.
My friend still uses C even though he has C++ available. I'm trying to get him to use C++ but he doesn't seem to like it. Gotta do something about it because what he uses right now is just awful. Also his code is full of compiler specific features and functions. Real mess nightmare.
 
You can't make "C" guys "C++" guys.
 
Heh well I gotta try.
 
ergo this
 
then another weird question:

size_t i = heapsize / 2;
do {
heapify(i, heapsize);
} while (i--);
 
12:22 AM
Okay... what's heapsize and heapify?
 
@Kivin Can't stand Linus. His ego is just too big ..
 
you see - I use do-while because if I used for - then i underflows
 
@Tuntuni I don't disagree with much that he says, but he can get pretty preachy and pedantic.
 
@Kivin I'm reading Kormen's algorithms book and implementing algorithms one by one
 
Althought for a kernel, C does seem like a better choice.
 
12:23 AM
Kernel, yes, but that article stemmed from Git being written in C.
 
so heapsize is a size of the heap, and heapify is a function to maintain heap's main requirement
 
@Kivin Didn't read the whole thing, will now.
 
basically heapsize == data_vector.size()
 
@zerkms I'm probably not the one to be lecturing on algorithms; I have no real formal education in computer science to speak of.
What is heap's main requirement
 
@Kivin Hmm maybe he has a point.
 
12:26 AM
@Kivin: every child value is less than its parent
 
@Tuntuni Maybe he does. Maybe he does not. But he's a dickhead for saying some of the things he says.
 
@Kivin True.
 
but my main point was - how would you iterate over i in case if it's of a size_t type so that you cannot just for with i >= 0
 
@zerkms Sorry I missed the ...if I used for - then i underflows
 
for (size_t i = 10; i >= 0; --i)
will never stop
so I had to use weird do-while instead
 
12:28 AM
(i = 0)-- becomes UINT32_MAX
 
@zerkms because it wraps around ^
 
yep
 
i != -1u
 
so how would you write a loop
 
But really I use signed types.
 
12:29 AM
So make it > 0
 
isn't i != -1u too tricky?
 
When it hits 0, it is out
then change 10 to 11
lol
 
@Tuntuni it's tricky as well isn't it?
 
@zerkms No. But I limit my use of unsigned types for bit-level manips, so it's par for the course.
 
Yeah .. Why are you doing it over decrementing though?
go from 0 to less than 10 then.
 
12:30 AM
Also an explicit loop is bound to raise eyebrows as well in my code.
 
@Tuntuni it's required to loop from N to 0
 
I think I would've just used a signed integer, since that's what you mean anyways.
 
and I wanted to avoid using size_t real_i = i - 1 and looping over N+1..1
 
@zerkms Ah.
 
@Kivin but isn't size_t what vector::size() returns?
 
12:32 AM
yes, you'll have to convert it to signed
Or else get a "signed / unsigned mismatch" warning
Also size_t can be 64 bits on 64 bit compiles.
 
so, at the moment @LucDanton proposed to use i != -1u
not sure if it will work
 
It'll do what you want, just isn't as expressive.
 
anything else you would use?
 
-1u is the correct number
 
Oh didn't think of that trick.
 
12:34 AM
I had this exact situation a handful of weeks back and just signed the integer. I don't think I considered the 32/64bit problem though.
 
size_t i = heapsize / 2;
do {
heapify(i, heapsize);
} while (i--);

so I it's not that bad then
 
Nope.
Nothin wrong with while loops.
 
Yeah but then you have an unnecessary variable outside.
(Unless you plan on reusing it.)
 
@Tuntuni I don't. But I don't have other choice in this case
 
All of my friends (who have just started learning C in school) declare everything right under **void** main().
So imagine what happens in for loops - the counter isn't reset.
And they ask me to come over and fix it.
 
12:37 AM
And you very nearly have a heart attack.
 
I'm staring at the code, can't locate the problem. And then I see a chain of variables.
@Kivin And this too.
Tableflipping almost occured.
Also, gotos are all over the place.
Because fuck loops.
 
zerkms, I guess you could wrap the whole block in an inline func if you didn't want the loose variable in scope, though that sounds like pedantic over-engineering.
 
@Kivin my first thought was to use it and then if (i-- != 0) { break; } but it's in fact the same
 
inline void heapify_heap(size_t i, size_t heapsize) {
	do {
		heapify(i, heapsize);
	} while(i--);
}

...
heapify_heap(heapsize / 2, heapsize);
 
while(i--), but yep
 
12:40 AM
err yeah
 
@Tuntuni Fuck C.
2
 
@Borgleader This.
 
That code from the Lower Paleolithic era that I had to debug was full of gotos.
 
@Kivin Mother of god.
 
What's worse is it was almost exclusively number crunching, and I don't have strong mathematics skills.
 
12:42 AM
Oh also, as a cherry on top, guess which IDE we use at school?
 
Notepad?
 
Ell
Dec?
 
mcedit
 
@Borgleader IDE, not an editor. :p
 
12:43 AM
@Ell Dec?
 
Ell
*dev c++?
 
Code::Blocks?
 
@Ell WE GOT A WINNERRRRR
I fucking hate that old piece of junk.
 
Ell
@kivin what the hell why?
 
@Ell I'm sorry, why what?
 
Ell
12:44 AM
Ive never used it, I just heard its bad haha
 
That's what I learned on, way back when. Wasn't even that long ago, either.
Turbo, not dev c++
 
Ell
@kivin why do you use that ide? Whatever it is :P
 
Good heavens. I don't.
I had to write C++ and PASCAL in it back in the late 90s.
 
Ell
Oh wait sorry I misread haha
 
You don't want to use Dev-C++, ever. I asked the teacher to install a more up to date IDE like Code::Blocks or something. "Okay" she said. "I'll check it out" she said.
Nothing happened ...
 
12:46 AM
Probably forgot about it ten seconds later if she's anything like over half the profs in the world.
 
Ell
Surely it can't be that bad
 
Oh, but it is.
 
I don't know much about it, just that it's old as balls.
 
The settings can be tweaked to make it more usable but still .. NO.
 
And whether it's "okay" or not, there's plenty of "better than okay" out there. I think that's the important point.
 
12:47 AM
Mhm.
 
Visual Studio Express for christ's sake.
 
But, looks like she's leaving and a new one is coming (which also doesn't have any idea about programming).
You should see how she teaches them C.
 
Ell
I just use a text editor and a build system and a terminal
 
Hell, even in 98 my high school got a brand new copy of Visual C++ 6.0 for every computer.
 
"#include <stdio.h> is something you HAVE TO HAVE. If you program doesn't work it is usually because you forgot this line." moves on without actually explaining what this code does.
 
12:49 AM
Is she the sort of "read out a textbook" kind of prof?
"The textbook says you have to do this, so DO IT"
-_-'
 
Ell
How can there be so many bad professors. I think its just this room which attracts people with bad professors :L
 
@Kivin Yup. And I hate it so much.
I'm the only one that knows C++ in school right now (2 guys that also knew it now left for college).
So yeah .. sucks ..
 
In college, my one of my programming profs was teaching her VERY FIRST class EVER, after some decades in the industry.
 
No one to code with. No projects to work on.
 
I think she made a better professional than a teacher.
 
Ell
12:51 AM
I'm probably not going to uni
 
I got an assignment back with a red pen line stroked from corner to corner, and big letters "NO." She never explained what she meant.
(We had to print code on paper and hand it in)
 
I can't wait to get to college to actually meet some people who like programming.
@Kivin Lol
Then I hope I'll actually work on a project.
Because this right now is boring me out of my mind.
 
Do this day, I have no idea what "NO" means. It compiled and ran, and was miles ahead of anything the other students wrote. It was their first look at C++ and I had been writing it since Grade 10.
 
Maybe she didn't understand it :P
 
It crossed my mind :P
 
12:53 AM
@Borgleader Haha, probably that.
 
It was hardly that complicated, either. Just a DOS console graphical calendar using no standard time functions. Hand done arithmetic.
 
"DOS console graphical calendar" made is sound like rocket science.
I guess it was because of how I read it. Awesome. :D
 
Basically just "ascii art" to print out a calendar that shows the current month.
If she wasn't happy with my paper, I'm sure she could have handled it better than putting a big slash through it and writing "NO" though. She didn't return to teach a second semester.
 
HAhahaha
Rrerererereeejectedddd.
 
Morning.
 
1:05 AM
Hey
 
`std::queue`
http://xkcd.com/853/
 
@Borgleader I'll join you. FUCK C!!!
 
Linus Torvalds would have a heart attack.
 
Lol. How to kill Linus: yell "FUCK C!" from the top of your lungs when you see him.
 
1:08 AM
Many said "FUCK UNIX!" and Linux was born.
 
Har har
 
Just like C++ is to C.
@Kivin OK. Whatever. FUCK GCC!
 
Indeed, fuck GCC
TIL what clang is.
 
so, I have this somewhat large tree; each node contains a vector of children....and deleting some children at the top gives me a stack overflow :S
 
Does deleting a child at the top drill down with deep recursion and delete all of its children or something?
 
1:19 AM
well, yeah. when the children are deleted, the vectors they contain are destroyed and delete their children etc etc
 
Ell
Maybe is trying to delete its self
 
@Ell Tall tree = legitimate stack overflow.
 
the thing is, the tree isn't even very tall. I think.
It might be quite wide though
but I don't see how that would cause an overflow :S
 
When the debugger catches the overflow, are you pushing a big load of nonsense on to the stack, or excessively deep in recursion or something?
 
what?
 
1:22 AM
What's the stack trace look like during the overflow
 
Everything hurts...
 
I just started Guild Wars 2 with nVidia Surround turned on
O.M.G.
 
@Kivin it's vector destructors all the way down
3
 
If the tree isn't that tall, can't be that far down
 
How much memory devoted to holding its place in the stack would occur for each node?
 
Ell
1:24 AM
Try allocating a tonne of stack
 
@melak47 The path to hell is apparently lined with vector destructors
 
Sup?
 
it#s these few lines a billion times
 
Vectors allocate on the heap. Somewhat unlikely for a stack overflow.
 
1:25 AM
and then at the end it's
ntdll.dll!0000000076d5417d() Unknown
kernel32.dll!00000000767a300a() Unknown
> msvcr110d.dll!_free_base(void * pBlock) Line 50 C
msvcr110d.dll!_free_dbg_nolock(void * pUserData, int nBlockUse) Line 1433 C++
msvcr110d.dll!_free_dbg(void * pUserData, int nBlockUse) Line 1265 C++
msvcr110d.dll!operator delete(void * pUserData) Line 54 C++
 
VS's std::vector only costs ~8 bytes.
 
@MarkGarcia all the vectors (except one) are on the heap anyway
 
@MarkGarcia The size of the stack frame and organization of the stack are unrelated to the size and organization of the structure you're operating on.
 
@melak47 He means the vector itself, not the data it stores.
 
@melak47 Then it's more unlikely for a stack overflow.
 
1:27 AM
@Kivin yes, me too
 
Oh, my bad.
 
all my tree nodes except the root one are on the heap
 
I wonder if that would work for a game. Spending bytes to remember stuff. Hm...
 
there's 4385 lines in my stack trace between main() and the last vector/allocator destructor ._.
 
Where's the recursion coming from
If you're 4385 stack frames deep, you're going to overflow
 
1:30 AM
it's coming from vector.erase
 
We know the tree is wide but not tall, so how is that recursing excessively
 
@Kivin I think the tree is wide but not tall
if the heuristic sucks it might be going deep
 
I blame Microsoft.
 
Can you re-write the algorithm to drill down to the bottom, and delete in a bottom-up fashion instead of top-down?
 
@Kivin no, I get a stack overflow :p
 
1:32 AM
You're calling erase() at the top and it's drilling down for you, right?
 
well, that#s what I have now
I also have code that needs to drill down and remove the leaf nodes from some other structures
 
guys, have I made any typical newbie mistakes here: pastebin.com/HMBeehJs
 
and that gets a stack overflow getting there
 
or, what newbie mistakes have I made there (i'm sure there are)
 
@melak47 Can you use a while loop and a heap stack to push down, rather than recursion?
 
1:36 AM
Why is Quicksort in a class
 
@Rapptz Because everything needs to be in a class, with matching standard design patterns. :)
 
@Kivin I can do away with the recursion in my other code, but vector.erase?
 
@melak47 I'm thinking about deleting the bottom-most vectors first, the ones with no children, then popping the stack and deleting the next ones. So they don't chain a zillion destructors.
 
@Kivin mm. I don't necessarily have all the leaf nodes available though. I'd need to keep them in another list I guess.
 
You can't obtain the children of a particular child?
 
1:40 AM
@Kivin no, I just don't keep all the leaves stored, I remove those from the "active list" that do not warrant further expansion
 
Problematic.
 
I guess I could create a list that has all the leaf nodes, at the expense of some more memory
 
Might deserve a full blown stack overflow question with the relevant objects explained so the experts can figure out something smarter than what I've got.
 
first I'll add some debug code that measures how deep the deepest nodes actually are.
 
Fair enough
Last week I debugged some code that recursed once for every pixel in an image. Problem was, the author wrote it back in the 80s when the images were only 320x160. It didn't like me elevating the constants to 4000x2000.
 
1:42 AM
if the heuristic is crap it might be doing a depth first search and drilling 10 million nodes deep, instead of having ~10 million nodes at a maximum depth of ~4-5
 
Yeah, that would overflow for certain.
 
:3
> 11,582,044 nodes searched in 10,890.014 ms. 1,063,547.209 nodes/s
> tree has maximum depth of 21,955,387,490,893,920 plies
...how the hell is my tree deeper than the number of nodes I have
 
plies?
 
rofl
twenty-one quadrillion nodes. Houston, we have a problem.
 
I blame Microsoft.
 
1:56 AM
Haha Microsoft is always the guilty one, no matter what.
 
If not Microsoft, then blame Electronic Arts.
 
It occurs to me, when ripping out your hair when working on projects is not a good time to consider whether or not to give up the project...
 
@Kivin Yes!!
 
@Pawnguy7 Or is that exactly the time to think about giving up the project
 
Perhaps. But often I seem to be blinded by frustration, and when I look back... well, it was bad, but not as much as it seemed.
 
1:58 AM
So I suppose the question is, is there light on the horizon? How soon can you get back to your happy place? :p
 

« first day (961 days earlier)      last day (3984 days later) »