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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.