添加 noexcept 会破坏二进制兼容性吗?
Does adding noexcept break binary compatibility?
简单的问题:如果改变这个:
void someMethod();
至
void someMethod() noexcept;
它会破坏二进制兼容性,还是方法签名保持不变?
方法签名是否保持不变?
是的。 https://en.cppreference.com/w/cpp/language/noexcept_spec :
Functions differing only in their exception specification cannot be
overloaded (just like the return type, exception specification is part
of function type, but not part of the function signature) (since
C++17).
它会破坏二进制兼容性吗?
可能不会,但标准不能保证任何事情(据我所知)。
简单的问题:如果改变这个:
void someMethod();
至
void someMethod() noexcept;
它会破坏二进制兼容性,还是方法签名保持不变?
方法签名是否保持不变?
是的。 https://en.cppreference.com/w/cpp/language/noexcept_spec :
Functions differing only in their exception specification cannot be overloaded (just like the return type, exception specification is part of function type, but not part of the function signature) (since C++17).
它会破坏二进制兼容性吗?
可能不会,但标准不能保证任何事情(据我所知)。