Ad hoc polymorphism and heterogeneous containers with value semantics

Different alternatives It is possible. There are several alternative approaches to your problem. Each one has different advantages and drawbacks (I will explain each one): Create an interface and have a template class which implements this interface for different types. It should support cloning. Use boost::variant and visitation. Blending static and dynamic polymorphism For the … Read more

‘size_t’ vs ‘container::size_type’

The standard containers define size_type as a typedef to Allocator::size_type (Allocator is a template parameter), which for std::allocator<T>::size_type is typically defined to be size_t (or a compatible type). So for the standard case, they are the same. However, if you use a custom allocator a different underlying type could be used. So container::size_type is preferable … Read more