1. template
template <typename T>
원하는 타입을 넣어주면 알아서 변형
>
Vector<int> int_vec;
Vector<std::string>
: 활용
2. C++ 기본처리단위 : 1byte
<> bool : 1bit
>
Vector<bool> 따로 처리
>>
템플릿 특수화 (template specialization)
template <>
class Vector<bool>
data(new unsigned int[n / 32 + 1]), capacity(n / 32 + 1), length(0)
int 형으로 생성한 공간에 bool 로 채우면
4byte = 32bit 즉, 32개의 bool
3.
bool operator[](int i) { return (data[i / 32] & (1 << (i % 32))) != 0; }
비트 and 연산 후 0이 아니라면 return 1
" " return 0
// AND 연산 : 값 보존 > 1
: 초기화 (0) > 0
함수 템플릿 (Function template)
함수 객체 (Functor): 함수인척 하는 객체
> 함수 인자로도 넘길수있음
폴드형식
return (... + nums);
// 9.3장