이펙티브 C++을 읽는 중에 처음보는 hack이 있어서 기록해두고자 한다. 연산자 오버로딩을 할 때 상수(const) 버전/비상수 버전을 나눠서 오버로딩할 수 있는데, 반환 타입에 const가 있냐없냐 차이일 뿐 하는 역할은 같으니 다음과 같은 방법을 통해 코드 중복을 줄일 수 있다.class TextBlock{public: const char &operator[](std::size_t position) const { ... return text[position]; } char &operator[](std::size_t position) { return const_cast( static_cast(*this)[positio..