Apr 12, 2022

[C++] noexcept constructor

Reference:

Using noexcept as operator and making constructor as noexcept.

e.g.
template<typename T>
struct Holder
{
    T value;

template<typename... Args>
    Holder(Args&&... args)
        noexcept(noexcept(T(std::forward<Args>(args)...))) :
        value(std::forward<Args>(args)...) {}
};

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.