본문으로 건너뛰기

C++ STL

Container

Ref: https://docs.microsoft.com/cpp/standard-library/stl-containers

Sequence container

std::vector

#include <vector>

template <class Type, class Allocator = allocator<Type>>
class vector;

If you are using the C style API, use std::vector::data() to get a pointer to the first element.

std::array

#include <array>

template <class Ty, std::size_t N>
class array;

If you are using the C style API, use std::array::data() to get a pointer to the first element.

std::deque

#include <deque>

template <class Type, class Allocator = allocator<Type>>
class deque;

std::list

#include <list>

template <class Type, class Allocator = allocator<Type>>
class list;
#include <forward_list>

template <class Type, class Allocator = allocator<Type>>
class forward_list;

Associative Container

std::map

#include <map>

template<class Key,
class Type,
class Traits = less<Key>,
class Allocator = allocator<pair<const Key, Type>>>
class map;

template<class Key,
class Type,
class Traits = less<Key>,
class Allocator = allocator<pair<const Key, Type>>>
class multimap;

std::unordered_map

#include <unordered_map>

template<class Key,
class Ty,
class Hash = std::hash<Key>,
class Pred = std::equal_to<Key>,
class Alloc = std::allocator<std::pair<const Key, Ty>>>
class unordered_map;

template<class Key,
class Ty,
class Hash = std::hash<Key>,
class Pred = std::equal_to<Key>,
class Alloc = std::allocator<Key>>
class unordered_multimap;

std::set

#include <set>

template<class Key, class Traits = less<Key>, class Allocator = allocator<Key>>
class set;

template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
class multiset;

std::unordered_set

#include <unordered_set>

template<class Key,
class Hash = std::hash<Key>,
class Pred = std::equal_to<Key>,
class Alloc = std::allocator<Key>>
class unordered_set;

template<class Key,
class Hash = std::hash<Key>,
class Pred = std::equal_to<Key>,
class Alloc = std::allocator<Key>>
class unordered_multiset;

Container adapter

std::queue

#include <queue>

template<class Type, class Container = deque<Type>>
class queue;

template<class Type,
class Container = vector<Type>,
class Compare = less<typename Container ::value_type>>
class priority_queue;

std::stack

#include <stack>

template <class Type, class Container = deque <Type>>
class stack;