Building Well-Behaved Type Relationships in C++