fork(2) download
  1. #include <iostream>
  2.  
  3. template <typename Derived>
  4. struct CRTP {
  5. static constexpr int num() { return Derived::value + 1; }
  6. };
  7.  
  8. struct A : CRTP<A> {
  9. static constexpr int value = 5;
  10. };
  11.  
  12. int main()
  13. {
  14. std::cout << A::num();
  15. return 0;
  16. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
6