|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
Just a guess, but is that your problem?
http://www.cplusplus.com/reference/iterator/reverse_iterator/base/
The base iterator is an iterator of the same type as the one used to construct the reverse_iterator, but pointing to the element next to the one the reverse_iterator is currently pointing to (a reverse_iterator has always an offset of -1 with respect to its base iterator).
|
yes that was the problem. I guess i should have looked it up, thought i was just a straight mapping. I used base() before and don't remember dealing with that either. Thank you.
|
|
|
On March 31 2014 13:12 icystorage wrote: wrong thread
Though you were in the Big Progaming Thread, right?
|
nope lol. had some topic but i thought it was more fit in the 'ask and answer stupid questions' thread
|
On March 30 2014 21:04 spinesheath wrote:Also if this is C/C++, you should prefer: if (null == instance)
In any case, there's no real norm to that. Just do it consistently.
I prefer to see which variable is being assessed in the if statement before seeing what is it put against.
For me it was always:
if ( instance == NULL ) { return; }
|
As I said, I find the C/C++ version harder to read too, but it provides that little extra safety against typos. In languages like C# where you don't have the stupid implicit pointer to bool cast, you don't need it.
|
Well, the best way to write it and avoid any confusion would be this:
if ( !instance ) { return; }
Personally, I only use NULL pointer only in ANSI C when releasing memory after malloc. Just a habit I acquired which lets me identify methods that are there only to invoke release on a glance.
|
On April 01 2014 04:38 Manit0u wrote:Well, the best way to write it and avoid any confusion would be this: if ( !instance ) { return; }
Personally, I only use NULL pointer only in ANSI C when releasing memory after malloc. Just a habit I acquired which lets me identify methods that are there only to invoke release on a glance. You're using the still stupid implicit pointer to bool conversion there. And you have to know that there is an implicit conversion when you read/write that or else you're just banking on something that "seems to work", which is a really dangerous place to be in with C/C++.
|
it doesn't get more unequivocal than doing an equal to with a nullptr in c++ at least. don't even have to see the type of instance to deduce what's going on.
|
On April 01 2014 03:52 spinesheath wrote: As I said, I find the C/C++ version harder to read too, but it provides that little extra safety against typos. In languages like C# where you don't have the stupid implicit pointer to bool cast, you don't need it. Or you could compile with warnings as errors, then you get the best of both worlds - compiler error when you typo, and you don't have to make your code awkward to read ^^
|
On April 01 2014 06:18 Cyx. wrote:Show nested quote +On April 01 2014 03:52 spinesheath wrote: As I said, I find the C/C++ version harder to read too, but it provides that little extra safety against typos. In languages like C# where you don't have the stupid implicit pointer to bool cast, you don't need it. Or you could compile with warnings as errors, then you get the best of both worlds - compiler error when you typo, and you don't have to make your code awkward to read ^^ Except that you now end up having to #pragma you way out of warnings, which are dangerous as well as they are now ignored on a whole line 
And potentially silly ones - as an example, I work with embedded as part of my job, and there's a simple macro that's nice to use
#define _BV(bit) (1 << (bit))
Combined with #define you now use code like this
#define SHIELD_UP 0 #define SHIELD_DOWN 1 #define SHIELD_MOVING 2 #define SHIELD_ERROR
if(ui8Input & _BV(SHIELD_UP)) { /* do something */ } else if(ui8Input & _BV(SHIELD_DOWN)) { /* do something else */ }
And so on - by the way, spot the compiler warning in the above 
Yep - it's this line
ui8Input & _BV(SHIELD_UP)
The warning is simply that the shift does not have any effect - but if you remove it, you may hide a bug that's surprisingly hard to notice, because the macro and define are both super simple - which is why I dislike "treat warnings as errors"
Of course you shouldn't have any warnings - but it's just as dangerous to #pragma them out or annoying to set warnings as error
|
bagsholt works for protoss.
|
Holy crap, I almost got a heart attack...
I got a small gig regarding the creation of a simple file format converting program for a company. Took me several days but I managed to do it (had to be in C# in which I didn't do anything before that). I let them know I'm ready to show and test the app with users to spot and get rid of any quirks that might still be there. In preparation I've decided to clean up some stuff on my machine, I had 2 folders with the same name, one in my workspace area and one outside of it. Without thinking much I delete the one that's outside the workspace... You guessed it, that was the finished app and in the workspace was the "backup" that was basically at the start of it, non-functional and useless. Had to sit there to 5 a. m. re-creating the app, doing stuff quick and dirty (gone are all the methods testing for file validity, value testing stuff etc.) but it works as intended if you do everything as you're supposed to.
Testing starts today, I don't have time to fix it any further until then. Crossing my fingers...
|
holy crap justified. good luck.
|
im actually pissed reading that lol. im like "WHY WOULD YOU DELETE STUFF IN A CRITICAL MOMENT?!"
|
On April 01 2014 16:36 icystorage wrote: im actually pissed reading that lol. im like "WHY WOULD YOU DELETE STUFF IN A CRITICAL MOMENT?!"
I was working crazy hours and my brain didn't process stuff as intended...
|
On April 01 2014 17:41 Manit0u wrote:Show nested quote +On April 01 2014 16:36 icystorage wrote: im actually pissed reading that lol. im like "WHY WOULD YOU DELETE STUFF IN A CRITICAL MOMENT?!" I was working crazy hours and my brain didn't process stuff as intended...
What happened to version control?
|
On April 01 2014 18:10 MichaelEU wrote:Show nested quote +On April 01 2014 17:41 Manit0u wrote:On April 01 2014 16:36 icystorage wrote: im actually pissed reading that lol. im like "WHY WOULD YOU DELETE STUFF IN A CRITICAL MOMENT?!" I was working crazy hours and my brain didn't process stuff as intended... What happened to version control? "What's that?"
|
On April 01 2014 18:10 MichaelEU wrote:Show nested quote +On April 01 2014 17:41 Manit0u wrote:On April 01 2014 16:36 icystorage wrote: im actually pissed reading that lol. im like "WHY WOULD YOU DELETE STUFF IN A CRITICAL MOMENT?!" I was working crazy hours and my brain didn't process stuff as intended... What happened to version control?
There wasn't any. Didn't want to bother with doing it for such a small project that I was working alone with. Came back to bite me in the ass in the end.
|
|
|
|
|
|