Program Listing for File clonable.h
↰ Return to documentation for file (include/cpphots/interfaces/clonable.h)
#ifndef CPPHOTS_INTERFACES_CLONABLE_H
#define CPPHOTS_INTERFACES_CLONABLE_H
namespace cpphots{
namespace interfaces {
template <class Base>
struct ClonableBase {
virtual Base* clone() const = 0;
};
template <class Derived, class Base>
struct Clonable : public virtual Base {
Base* clone() const override {
return new Derived(static_cast<Derived const&>(*this));
}
using Base::Base;
};
}
}
# endif