Skip to content

Author Archives:

Deleting From A Collection in STL

28-Jul-10

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 […]

Cygwin setup.exe not a valid win32 application

23-Jul-10

I 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 […]

C++ Runtime Types: Find All Classes Derived From a Base Class (3)

19-Oct-09

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 […]

C++ Runtime Types: Find All Classes Derived From a Base Class (2)

18-Oct-09

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 { […]

C++ Runtime Types: Find All Classes Derived From a Base Class (1)

17-Oct-09

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-09

I 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 […]

In case you needed another reason not to use VC6

26-Aug-09

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.

ATL 3.0 (VS6.0) Control Creation Resource Leak

09-May-09

So yeah, this post isn’t about homeschooling.

Arrogance and humility

05-May-09

Arrogance 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-09

I 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. […]