I have a hurdle with noexcept specifier next to my copy constructor.
#include <memory>
#incldue <vector>
class Foo final {
public:
Foo() noexcept = default;
Foo(const Foo& oth) : impl_(std::make_unique<Foo::Impl>()) {} // <---
~Foo() noexcept = default;
private:
class Impl;
std::unique_ptr<Impl> impl_;
};
class Foo::Impl {
...
private:
std::vector<int> some_data;
}
I'm not sure if I should put noexcept next to copy constructor while there is std::make_unique that can throw bad_alloc.
Any help will be apreciated!
Aucun commentaire:
Enregistrer un commentaire