Martin Buchholz

Martin Buchholz's home page

Welcome.

Personal info

Thoughts on Computer Programming

Martin's Object System

Like many others before me, I've created an experimental object system (source code). Mine is implemented in C++, but tries to make styles of programming possible that C++ normally does not permit.

Implementing Smart References in C++

We try to revive an old idea, C++ smart references, using modern template-based methods. A novel C++ programming technique, the Doubly Curiously Recurring Template Pattern is developed. Boxing of value types within a smart reference framework is explored.

Smart Pointers and Inheritance-Based Type Conversions

We apply the smart reference implementation techniques to the related problem of integrating smart pointers with inheritance hierarchies. We are less pessimistic about solving this problem than Scott Meyers in his More Effective C++, Item 28.

Constraints for Function Template Parameters in C++

C++ has weak mechanisms for constraining template parameters. Previous work on template constraints (Bjarne Stroustrup and Jeremy Siek) has focused on generating better error messages when a template is instantiated with inappropriate types. We focus on a different problem — preventing a template from being instantiated at all. This allows function templates to be overloaded.

Idioms for Typesafe Enums in C++

C++ enums are convenient, but not typesafe. We explore alternatives for implementing typesafe enums in C++. Along the way we discover two novel idioms for programming in C++, the Enum Literal idiom and the Private Inherited Enum idiom.

The C++ Class Literal Idiom

The Enum Literal idiom developed previously is generalized and more deeply explored, in the context of a numeric class.

Builtin types have literal values, such as the integer 7. We try to create entities with similar properties for ordinary user-defined C++ classes.

A Typesafe Boolean Class for C++

We try to implement a boolean class for C++ with the same sensible semantics as the Java boolean type. The implementation is surprisingly difficult, using three distinct advanced template techniques.

Solving the C++ NULL Type Safety Problem

In C++ NULL is, exceptionally, even less typesafe than in C. We show how to restore the minimal safety of C.

Implementing alignof

There is no truly portable way to implement alignof. But in practice we can come up with a very good approximation.


Last modified: Sun Feb 19 21:47:37 PST 2023
Copyright © 2003 Martin Buchholz