Program Listing for File crtp-clone.h

Return to documentation for file (aslam_cv2/aslam_cv_common/include/aslam/common/crtp-clone.h)

#ifndef ASLAM_CV_CRTP_CLONE_H_
#define ASLAM_CV_CRTP_CLONE_H_

namespace aslam {

template<typename BaseType, typename DerivedType>
class Cloneable : public BaseType {
 public:
  typedef Cloneable Base;
  using BaseType::BaseType;

  virtual BaseType* clone() const {
    return new DerivedType(static_cast<const DerivedType&>(*this));
  };

  virtual ~Cloneable() {};
};

}  // namespace aslam

#endif  // ASLAM_CV_CRTP_CLONE_H_