책에는 헤더 include 하고 using namespace rel_ops; 하면 == < 연산 두 개만 정의하면 다른 연산들은 컴파일러가 알아서 만들어준다고 나와있는데
vs로 만들어서 해보니까 != 연산이 없다고 빌드가 안 됨;;;
내가 operator!= 연산 정의해주면은 빌드 되는데 왜 자동으로 안 만들어주는지 넘모 궁금한데 스택 오버플로우에 검색해도 못찾겟음;;;
그리고 저걸 C++17 표준으로 해놓고 빌드하면
std::iterator::difference_type': warning STL4015: The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17. (The header is NOT deprecated.) The C++ Standard has never required user-defined iterators to derive from std::iterator. To fix this warning, stop deriving from std::iterator and start providing publicly accessible typedefs named iterator_category, value_type, difference_type, pointer, and reference. Note that value_type is required to be non-const, even for constant iterators. You can define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning
이렇게 나오는데
start providing publicly accessible typedefs named iterator_category, value_type, difference_type, pointer, and reference
이게
이렇게 내가 직접 해주라는 거 맞음? 내가 직접 해주니까 빌드 되기는 하는데 상속 받는 것보다 존나 귀찮아짐
왜 deprecated 된 거지
https://en.cppreference.com/w/cpp/utility/rel_ops/operator_cmp
예제를 보면 해당 연산자를 직접 사용하는 걸 볼 수 있음. using namespace는 해당 블록에만 적용되고 std::copy안 까지 적용되진 않겠지. 그러니 rel_ops의 연산자를 사용하지 않을거고, 펑.
https://stackoverflow.com/questions/43268146/why-is-stditerator-deprecated
요약하면,
그 using들을 알 수 없어 명확성이 떨어져서 그렇다네.
근데 rel_ops나 iterator나 C++20가면 다 deprecated인데, C++도 이렇게 보면 누더기네.