Dealing with protected/private constructor/destructor for a CRTP design?
Consider the following code: #include <iostream> #include <type_traits> // Abstract base class template<class Crtp> class Base { // Lifecycle public: // MARKER 1 Base(const int x) : _x(x) {} protected: // MARKER 2 ~Base() {} // Functions public: int get() {return _x;} Crtp& set(const int x) {_x = x; return static_cast<Crtp&>(*this);} // Data members protected: int _x; }; // Derived class class Derived : public Base<Derived> { // Lifecycle public: Derived(const int x) : Base<Derived>(x) {} ~Derived() {} }; // Main int main() { Derived d(5); std::cout<<d.set(42).get()<<std::endl; return 0; } If