이 내용 가져오면서 ++98 스타일 긍정했다하는데
그게 아님.
애초에 RAII <- CPP 초창기때부터 함께했지만 대부분 안 지켰음
그래서 그걸 지키게 하기위해서 이동 시맨틱스 도입한게 C++11임
이펙티브 모던 C++이라는 이름답게 '모던 C++'를 가르키는 것.
저 내용 뭔지 설명해줌
In C++98, exception specifications were rather temperamental beasts. You had to summarize the exception types a function might emit, so if the function’s implemen‐ tation was modified, the exception specification might require revision, too. Chang‐ ing an exception specification could break client code, because callers might be dependent on the original exception specification. Compilers typically offered no help in maintaining consistency among function implementations, exception specifi‐ cations, and client code. Most programmers ultimately decided that C++98 exception specifications weren’t worth the trouble
->예외명세는 까다롭다. 그리고 클라이언트 코드 깨질 수 있다. 호출자가 예외명세에 의존하고 있었을 가능성이 높아서,
클라이언트 코드 간의 일관성을 전혀 자동으로 보장해주지 않았다
결국 대부분의 프로그래머는 C++98 예외 명세는 사용할 가치 없다고 판단함
During work on C++11, a consensus emerged that the truly meaningful information about a function’s exception-emitting behavior was whether it had any. Black or white, either a function might emit an exception or it guaranteed that it wouldn’t. This maybe-or-never dichotomy forms the basis of C++11’s exception specifications, which essentially replace C++98’s. (C++98-style exception specifications remain valid, but they’re deprecated.) In C++11, unconditional noexcept is for functions that guarantee they won’t emit exceptions.
->C++11 에서는 상황이 달랐음.
흑백으로 나눠서 이진 구분을 하게함
즉 C++98 스타일의 예외명세는 문법적으로 유효하나, 더이상 권장되지 않는다.
noexcept는 예외를 던지지 않는다는걸 선언하는 방시깅고
c++11 에서는 noexcept 함수가 절대 예외를 발생시키지 않음을 보장함
어떤 함수에서 noexcept를 선언할지 여부가 '인터페이스' 설계의 핵심이라는 걸 보여주는 내용임
그래서 C++98식으로 하라는게 아니라
가능한한 noexcept를 선언해서 모던 C++ 식으로 하되
어쩔 수 없는 상황에서 예외 던지고, C++98식으로 안전 보장하라는거임
C++11에서는 copy대신 move를 쓰는게 자연스러운 최적화다(이또한 내가 한 말)
기존 C++98 코드들은 push_back이 강한 예외 안전성을 보장한다나는 가정하에 작성되었지만,
C+11 구현체들은 복사 move로 교체하려면 해당 move 연산이 절대 예외를 던지지 않는다는 사실을 알아야한다라고 설명함
따라서 이전 내 설명대로
C++11 이상으로 '모던'하게 짜라는거지 C++98 내용 따르라는 말이 아니다,
뭘 왜곡했다는거냐 98 RAII가 안전하지 않다는 네말을 얘기한거뿐인데
저 내용이 그 내용임. 완전하게 안전하지 않다는거임
“In C++98, exception specifications were rather temperamental beasts … Most programmers ultimately decided that C++98 exception specifications weren’t worth the trouble.” 이게 RAII 기반의 예외안전성 완전 보장을 못한다는 뜻이야
왜 설명 제대로 못해줘도 알아 쳐먹질 못하냐
"대부분 안지켰음" 이러고 있네 std::vector가 그거니까 그걸로 얘기하고 있는걸 가지고
@ㅇㅇ 아, 진짜 갑갑해. 대부분 안 지킨것도 씹팩트고, 그리고 저 예외 안전성이 보장 안된다는것도 저 내용이라고
@ㅇㅇ C++98이 예외안전성을 완전 보장이 어렵다-> RAII 유지가 어렵다. 저 당시 RAII가 뭐냐? Fire and Forgot인데, 호출자 일관성이 유지가 안되면 그게 RAII냐? 진짜 씨발
RAII를 왜 쓰는지조차 모르냐 혹시?
https://isocpp.org/wiki/faq/exceptions#finally
@ㅇㅇ 너 진짜 걍 이해도가 아예 없구나. 니는 니 언어 철학에 대한 이해도가 없으니까 걍 차단함
@ㅇㅇ 떡하니 마이어책에도 레거시 코드라고 적혀있는데