Boost logo

Boost :

Subject: Re: [boost] [poly_collection] Small review
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2017-05-09 13:46:58

On 09/05/2017 13:39, Joaquin M López Muñoz via Boost wrote:
> typeid is used extensively throughout the library, both the static
> (typeid(T)) and the dynamic
> version (typeid(x)) --the latter only in base_collection and in one spot in
> boost/poly_collection/detail/segment.hpp. std::type_index is part of the
> public interface.
> Boost.TypeIndex could be in principle optionally used for RTTI-less
> scenarios, but I don't really
> know whether this is a common enough / requested scenario.

I was planning my own review after the library review was closed (so
that the review manager does not influence other reviewers) and one of
the comments was related to RTTI, so I'm making my comments now for

Basic examples in the documentation are based on games concepts (sprite,
warrior, goblin, ...) and usually in game development builds RTTI is
disabled although polymorphism is widely used. My comment is about
making the runtime-identification configurable by the user

I can imagine an application where all classes are known and a custom
typeid can be generated and stored in the abstract base class of every
type, so that it can be retrieved via an inline function, without
noticeable run-time overhead. It could just cache a std::type_info pointer.

I think a lot of game engines use their own RTTI framework that could be
easily plugged into PolyCollection (maybe as an additional TypeIdTraits
template parameter). Something like:

class typeid_traits
    typedef /**/ type_info_t;
    typedef /**/ type_index_t;

    template<class T>
    static type_info_t typeid_of(T *p);

    //Usage: const type_info_t &ti = typeid_of<MyClass>();
    template<class T>
    static type_info_t typeid_of();

type_index_t should be constructible from type_info, hashable and

This type of abstraction could support Boost.TypeInfo and many other
approaches. Anyone sees this customization useful?



Boost list run by bdawes at, gregod at, cpdaniel at, john at