Wednesday, September 29, 2010

Template Specialization

'Template specialization' is to 'compile-time if' as 'virtual function' is to 'run-time if'.

Reference: Modern C++ Design by Andrei Alexandrescu. Addison-Wesley, 2001, p. 54.

Many times when you see switching on types, it indicates a non-object-oriented design. Some of the places where it is usually okay are:

1) when unmarshalling data from across a wire; and

2) when implementing a virtual constructor

No comments:

Post a Comment