Skip to content

Instantly share code, notes, and snippets.

@deque-blog

deque-blog/Clonable.hpp

Last active Sep 8, 2017
Embed
What would you like to do?
template<typename Derived>
struct Clonable
{
virtual ~Clonable() = default;
std::unique_ptr<Derived> clone()
{
return std::unique_ptr<Derived>(cloneImpl());
}
protected:
virtual Derived* cloneImpl() const = 0;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment