본 문서에서는 C++에서 사용하는 표준 라이브러리 등의 구현을 위하여 자주 사용되는 C++의 하부구조수준의 라이브러리들에 관한 내용을 다룬다.
최종수정일 : 2023.04.05
작성 기준 C++ Version : C++98
` #include <memory> template <class T> class allocator; `
member | definition | represent |
---|---|---|
value_type | T | Element type |
pointer | T* | Pointer to element |
reference | T& | Reference to element |
const_pointer | const T* | Pointer to const element |
const_reference | const T& | Reference to const element |
size_type | size_t | Quantities of elements |
difference_type | ptrdiff_t | Difference between two pointers |
rebind<Type> | member class | Its member type other is the equivalent allocator type to allocate elements of type Type |
member | function |
---|---|
(constructor) | Construct allocator object (public member function) |
(destructor) | Allocator destructor (public member function) |
address | Return address (public member function) |
allocate | Allocate block of storage (public member function) |
deallocate | Release block of storage (public member function) |
max_size | Maximum size possible to allocate (public member function) |
construct | Construct an object (public member function) |
destroy | Destroy an object (public member function) |
작성 기준 C++ Version : C++98
` #include <string> template <class charT> struct char_traits; template <> struct char_traits<char>; template <> struct char_traits<wchar_t>; //Details template<class charT> struct char_traits { typedef charT char_type; typedef INT_T int_type; typedef POS_T pos_type; typedef OFF_T off_type; typedef STATE_T state_type; static char_type to_char_type(const int_type&); static int_type to_int_type(const char_type&); static bool eq(const char_type&,const char_type&); static bool eq_int_type(const int_type&, const int_type&); static int_type eof(); static int_type not_eof(const int_type&); static void assign(char_type&,const char_type&); static bool lt(const char_type&, const char_type&); static int compare(const char_type*, const char_type*,size_t); static size_t length(const char_type*); static const char_type* find(const char_type*,int n, const char_type&); static char_type* move(char_type*, const char_type*,size_t); static char_type* copy(char_type*,const char_type*, size_t); static char_type* assign(char_type*,size_t, const char_type&); }; `
char_traits는 별도의 멤버 변수를 가지지 않고, 오직 추상화된 데이터형 정의를 갖는다.
Member function | Description |
---|---|
assign | Assigns one character value to another. |
compare | Compares up to a specified number of characters in two strings. |
copy | Copies a specified number of characters from one string to another. |
_Copy_s | Copies a specified number of characters from one string to another. |
eof | Returns the end-of-file (EOF) character. |
eq | Tests whether two char_type characters are equal. |
eq_int_type | Tests whether two characters represented as int_types are equal. |
find | Searches for the first occurrence of a specified character in a range of characters. |
length | Returns the length of a string. |
lt | Tests whether one character is less than another. |
move | Copies a specified number of characters in a sequence to another, possible overlapping, sequence. Deprecated. Use char_traits::_Move_s instead. |
_Move_s | Copies a specified number of characters in a sequence to another, possible overlapping, sequence. |
not_eof | Tests whether a character is the end-of-file (EOF) character. |
to_char_type | Converts an int_type character to the corresponding char_type character and returns the result. |
to_int_type | Converts a char_type character to the corresponding int_type character and returns the result. |
` #include <iterator> template < class Category, class T, class Distance = ptrdiff_t, class Pointer = T*, class Reference = T& > struct iterator { typedef T value_type; typedef Distance difference_type; typedef Pointer pointer; typedef Reference reference; typedef Category iterator_category; }; `
iterator는 별도의 멤버 변수를 가지지 않고, 오직 추상화된 데이터형 정의를 갖는다.
Member function | Description |
---|---|
advance | Advances the iterator it by n element positions. |
distance | Calculates the number of elements between first and last. |
begin | Returns an iterator pointing to the first element in the sequence |
end | Returns an iterator pointing to the past-the-end element in the sequence |
prev | Returns an iterator pointing to the element that it would be pointing to if advanced -n positions. |
next | Returns an iterator pointing to the element that it would be pointing to if advanced n positions. |
inserter | Constructs an insert iterator that inserts new elements into x in successive locations starting at the position pointed by it. |
front_inserter | Constructs a front-insert iterator that inserts new elements at the beginning of x. |
back_inserter | Constructs a back-insert iterator that inserts new elements at the end of x. |
make_move_iterator | A move_iterator is an iterator adaptor that adapts an iterator (it) so that dereferencing it produces rvalue references (as if std::move was applied), while all other operations behave the same. |
https://cplusplus.com/reference/ios/ios_base/?kw=ios_base
https://modoocode.com/144