Deleting from a collection is hard in STL. Or rather, it’s subtle. Which is roughly equivalent to hard. Jim Beveridge talks about STL erase in his latest blog post and that inspired me to spend some time messing around with STL containers last night. You can remove all even numbers from a set with Jim’s […]
Author Archives:
Deleting From A Collection in STL
28-Jul-10I ran into this error – “setup.exe is not a valid win32 application” the other day while I was trying to upgrade cygwin (1.5 -> 1.7) on an old laptop. Underlying problem was that I was upgrading under a different account than had been used to originally install cygwin. Switching to that account and running […]
Working on a way to find all the derived classes of a base class: part 1 is here, discussing the motivation and frame of the problem. Â Part 2 is here, discussing one approach that works but not for me. The problem is laziness: if I am in a hurry to put in a new error […]
Working on a way to find all the derived classes of a base class: part 1 is here, discussing the motivation and frame of the problem. StackOverflow gives a pointer to meatspace (a blog), where he’s got a solution involving factory methods and a single macro per class. class Base; typedef Base* (*base_creator)(void); class BaseRegistry { […]
I’m working on a program in C++, recently converted from C. Â I’m redesigning the error logging subsystem to have type-safety, log-to-database, and also to make it possible to generate a list of all the errors in the system. Â So what I’ve decided to do is have a base class CError, and require that all the […]
Finding C-Style Casts
06-Oct-09I updated this script to make it work a little better with Visual Studio (VS6 anyway). Â It now uses the paren-printing convention so you can use F4 to find the next cast. Requires perl. Â Add it as a tool under Tools | Customize ; Command is the path to your perl.exe, Arguments is path to […]
The MSVC6 implementation of STL omits push_back() on std::basic_string, meaning that std::string s,s2; std::copy( &s[0], &s[n], std::back_inserter( s2 ) ); gives a syntax error; but it shouldn’t.
So yeah, this post isn’t about homeschooling.
Arrogance and humility
05-May-09Arrogance and humility are two qualities that are essential to programmers (perhaps, to everyone?). It’s hard to maintain a balance between these two opposite behaviors, so practice is essential. Humility is important to prevent wasting your own and other people’s time. The simple manifestation of this is in troubleshooting. If something breaks in a system […]
More about Python
20-Feb-09I just realized that there is an (obvious) biblical objection to the language Python. Â Adam and Eve used C, naturally. Â The Python came into the Garden of Eden as a tempter, bringing dynamic language features. Â Adam and Eve succumbed to temptation and were thrown out of the garden, and now they… uh… analogy breaks down. […]