Skip to content

Instantly share code, notes, and snippets.

@afabri
Created November 22, 2019 16:13
Show Gist options
  • Save afabri/a6df1813b8d13fabe1e7d1b889d84180 to your computer and use it in GitHub Desktop.
Save afabri/a6df1813b8d13fabe1e7d1b889d84180 to your computer and use it in GitHub Desktop.
#include <Eigen/Dense>
struct Base {
virtual Base* clone() const = 0;
};
template <class T>
struct Derived : public Base {
virtual Base* clone() const {
Derived* d = new Derived<T>();
return d;
}
Derived(T t = T())
: Base(), t(t)
{}
T t;
};
int main(int argc, char** argv)
{
typedef Eigen::Matrix<double, 4, 4> Matrix;
Derived<Matrix> derived;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment