# **[](https://en.cppreference.com/w/cpp/header/scoped_allocator)** provides `std::scoped_allocator_adaptor`, which propagates an allocator to nested containers. Normally, a vector's allocator doesn't apply to the strings it contains; this adaptor fixes that, ensuring all nested allocations use the same custom allocator. Use it only when you have a custom allocator you want to apply recursively throughout a container hierarchy. ## Example This example creates and uses a vector with string elements, demonstrating nested container allocation. ```cpp // compile: g++ -std=c++11 -o scopedallocatorexample scopedallocatorexample.cpp // run: ./scopedallocatorexample // description: allocator propagation with scoped_allocator_adaptor #include #include #include #include int main() { using string_t = std::string; using vector_t = std::vector; vector_t v; v.push_back("hello"); std::cout << "vector size: " << v.size() << "\n"; std::cout << "first string: " << v[0] << "\n"; return 0; } ```