# C++ Dependent names **[Dependent names](https://en.cppreference.com/w/cpp/language/dependent_name)** are names in template code that depend on template parameters. When a dependent name is ambiguous (could be a type or value), the compiler assumes it's a value unless declared with `typename`. Writing `typename T::value_type` tells the compiler that `value_type` is a type member of `T`. Qualify dependent type names with `typename`; this is required by the standard and aids readability. ## Example This example shows dependent name disambiguation with typename keyword. ```cpp // compile: g++ -std=c++17 -o dependent dependent.cpp // run: ./dependent // description: dependent names require typename for type members #include #include #include template void process(T& container) { // Without typename, compiler doesn't know this is a type typename T::value_type value = container.at(0); std::cout << "Value: " << value << "\n"; } template struct Traits { // This typedef is a dependent type using type = T; }; template void use_traits() { typename Traits::type value{}; std::cout << "Trait type used\n"; } int main() { std::vector v{42}; process(v); use_traits(); return 0; } ```