CHAPTER 4

image

Overload Resolution

This chapter presents TMP techniques based on overload resolution.

The common underlying schema is as follows:

  • You want to test if type T satisfies a condition.
  • You write several static functions with the same name, say test, and pass them a dummy argument that “carries” type T (in other words, an argument that allows deduction of T, such as T*).
  • The compiler selects the best candidate, according to C++ language rules.
  • You deduce which function was used, either using the return type or indirectly from a property of this type, and eventually make a decision.

The first section introduces some definitions.

4.1. Groups ...

Get Advanced Metaprogramming in Classic C++ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.