The following code example is taken from the book
C++23 - The Complete Guide
by Nicolai M. Josuttis,
Leanpub, 2026
The code is licensed under a
Creative Commons Attribution 4.0 International License.
// raw code
#include <iostream>
template<typename T1, typename T2>
void foo(const T1&, const T2&)
{
std::cout << "different types\n";
}
template<typename T>
void foo(const T&, const T&)
{
std::cout << "same type\n";
}
int main()
{
int arr1[3] {};
int arr2[5] {};
foo(arr1, arr2); // two array of different size passed
foo(auto(arr1), auto(arr2)); // two pointers of same type passed
}