Standard Template Library (STL) là gì? Hãy kể tên một số container thường dùng.
Xem đáp án và giải thích
STL là nền tảng generic programming của thư viện chuẩn C++, xoay quanh container, iterator, algorithm và function object. Sequence container phổ biến gồm vector, array, deque, list, forward_list; associative container có thứ tự gồm map, set; biến thể unordered dựa trên hash; adaptor gồm stack, queue, priority_queue. Cần chọn container theo access pattern, quy tắc invalidation, ordering và yêu cầu độ phức tạp thay vì theo thói quen.
STL là nền tảng generic programming của thư viện chuẩn C++, xoay quanh container, iterator, algorithm và function object. Sequence container phổ biến gồm vector, array, deque, list, forward_list; associative container có thứ tự gồm map, set; biến thể unordered dựa trên hash; adaptor gồm stack, queue, priority_queue. Cần chọn container theo access pattern, quy tắc invalidation, ordering và yêu cầu độ phức tạp thay vì theo thói quen.
Hãy liên hệ trực tiếp kết luận với kiểu, lifetime, ownership, overload resolution hoặc library contract xuất hiện trong câu hỏi. Nếu kết quả phụ thuộc implementation hoặc vi phạm precondition, cần nói rõ thay vì chỉ đoán output.