I am currently writing a public library for vector and matrix operations.
My library, as it stands now, only accepts arithmetic types and complex numbers (by using std::complex<T>
).
Since I value-initialize an array of type T, where T might be std::complex<T>
, and since std::complex<T>
's default constructor is not noexcept
, I'm wondering whether it is the case to have my default constructor have a conditional noexcept for this single case, so that the constructor is noexcept only when T's default constructor is marked noexcept.
I don't know if that makes any sense; currently, I can't find a reason as to why this might be helpful. But on the other hand, I am completely unaware of what anyone using the library might do with it (they might, perhaps, store multiple Math::Vectors inside a std::vector
too, I guess?).
So long story short: I'm wondering whether something like this would make sense, to cover the case where std::complex<T>
is passed:
private:
T math_vector[Size]{}; // T might be std::complex
public:
constexpr Vector() noexcept(std::is_nothrow_default_constructible_v<T>) = default;