
Beman Dawes:
I'm going to attack variable-length keys/data in several steps.
1) Via a very simple string class that has a fixed maximum length, and has a sizeof() that maximum length + 1. Although this wouldn't be suitable for really demanding applications, it should be fine for a lot of every day programming. It is totally non-invasive, so is available right now. See http://github.com/Beman/Boost-Btree/blob/master/boost/btree/detail/fixstr.hp..., or use your own if you've already got such an animal.
Just fyi, I've been experimenting with a similar string -- http://webEbenezer.net/misc/lil_string.hh . If an operation would result in a string with length more than 255, an exception is thrown. This allows the length of the string to be marshalled with one byte. As you mention this limitation is not a problem in many circumstances. I'd quibble a little with it not being suitable for demanding applications. I think it is fine to use it in that context, but that you might need to also use other string classes. -- Brian Wood Ebenezer Enterprises http://webEbenezer.net (651) 251-9384