Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ここに私の関数テンプレートがあります:
template <typename T> void f(vector<T> &a) noexcept(noexcept( /* ??? */ ))
=の代入演算子が指定されTている場合、この関数が例外をスローしないように指定したいと思いますnoexcept。これを行う方法はありますか?
=
T
noexcept
これでそれを行うことができます:
template<typename T> void f(std::vector<T>& a) noexcept(std::is_nothrow_copy_assignable<T>::value) {...}
noexceptコピー代入T値自体が宣言されている場合に条件を設定しnoexceptます。move-assigning も考慮して、これをさらに進めることができますT。