Class Template Argument Deduction (CTAD) is a feature introduced in C++17 that allows the compiler to deduce the template arguments for class templates from the constructor arguments. This makes code more concise and avoids the need for explicit template arguments.

Example without CTAD:

#include <vector>
#include <iostream>

int main() {
    std::vector<int> vec = {1, 2, 3, 4, 5};  // Explicit template argument
    for (const auto& elem : vec) {
        std::cout << elem << " ";
    }
    return 0;
}

Example with CTAD:

#include <vector>
#include <iostream>

int main() {
    std::vector vec1 = {1, 2, 3, 4, 5};  // CTAD deduces std::vector<int>
    std::vector vec2 = {1.1, 2.2, 3.3};  // CTAD deduces std::vector<double>

    for (const auto& elem : vec1) {
        std::cout << elem << " ";
    }
    for (const auto& elem : vec2) {
        std::cout << elem << " ";
    }
    return 0;
}