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 […]
Category Archives: Uncategorized
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.
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 […]
New MFC App with ATL, VC6.0
11-Jan-09OK, so we’re still using VC6.0. Â Gluttons for punishment, I guess. I recently created a new MFC app and had some… opportunities getting it to compile, so I thought I’d document them here for the three other people in the world not on VC9. First: when you start a new MFC app and switch […]
STL lower_bound: set vs. list
01-Oct-08Commentor Paul asks why we would use a list instead of a set, since a set has an efficient lower_bound() method and has cheaper insertion/deletion than a sorted vector; set insertion also preserves iterators. First, recall the the lower_bound() on a list problem is purely a hypothetical, and I’m not using this data structure anywhere. […]
I added a new host to snapback a while ago and started getting these horrible messages mailed to me by cron every six hours.  The entire body of the email was: —link–dest arg does not exist: ../hourly.1 I finally fixed it today. The problem?  Snapback was backing up an empty directory.  One solution would be to […]
You know you’ve been coding for the Intel platform too long when “eax” looks more like a word than “wax”. I typed “wax”; it looked wrong, so I semi-consciously backspaced out and retyped it as “eax”. Which looked more correct. Then my conscious mind realized I really did want “wax” so I changed it back.