
Toon Knapen wrote:
I need an equivalent of type_traits::rank for a vector-matrix library I am working on so I thought about extending type_traits::rank for my own vector- and matrix-types. But is extending type_traits foreseen or even possible? And what is the best way to go about?
The easiest way of course is to add a specialization for boost::type_traits::rank in my project's sources but this is not a very clean solution because this would require that I add stuff to the boost-namespace in my own project. Ideas?
Unfortunately I think you need to define your own trait: the idea behind type-traits is that they work with the core C++ type system only, and that we don't extend them to classes that are "pretending" to be something else (like an array for example). Having just said that, I'm having trouble thinking of a reason why extending boost::rank in this way would cause problems in a way that extending is_pointer to smart-pointers would for example. So.... why not create your own traits class, call it rank if you want, place it in your projects own namespace, and have the primary template inherit from boost::rank. Does that make sense? John.