Curiously recurring template pattern: Difference between revisions

Content deleted Content added
Citation bot (talk | contribs)
m Alter: title, isbn. Add: title-link, date. Removed parameters. Some additions/deletions were actually parameter name changes. | You can use this bot yourself. Report bugs here. | Activated by User:Neko-chan | Category:Software design patterns | via #UCB_Category
Polymorphic copy construction: Less verbose example code.
Line 215:
virtual std::unique_ptr<AbstractShape> clone() const = 0;
};
 
// This CRTP class implements clone() for Derived
template <typename Derived>
Line 220 ⟶ 221:
public:
std::unique_ptr<AbstractShape> clone() const override {
return std::unique_ptrmake_unique<AbstractShape>{new Derived{>(static_cast<Derived const&>(*this)}});
}