私は現在、noexcept に頭を悩ませようとしています (ほとんどの人と同じように、古い「実行時例外仕様」を避けました)。noexcept の基本的な考え方は理解できたと思いますが、次のような状況で何が起こるかはわかりません。
class sample {
public:
sample() noexcept { }//this doesn't throw
sample(const sample & s) noexcept { }
sample(sample && s) noexcept { }
sample & operator=(const sample & s) noexcept {...}
sample & operator=(sample && s) noexcept { ... }
~sample() noexcept() { }//this should never ever throw
sample operator-() const { return *this * -1; }//assuming that there is a operator*…
sample & operator*=(const sample & s) noexcept { ... }
};
sample operator*(sample s1, const sample & s2) { return s1 *= s2; }//same problem as with operator-…
sample::operator- を noexcept として宣言しても安全ですか? (戻り時にコンストラクターを呼び出していることを考慮して)
編集: 質問の中心部分が明確ではなかったように思われるため、コード セクションを更新しました…</p>