fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Foo{
  5. Foo(int v) : value(v) {}
  6. int value;
  7. };
  8.  
  9. template<class T, T(*F)()>
  10. struct V {
  11. static const T s_default = F();
  12. };
  13.  
  14. Foo default_foo() { return Foo(3); }
  15.  
  16. struct FooContainer : public V<Foo, default_foo> {
  17. };
  18.  
  19. int main() {
  20. // your code goes here
  21. return 0;
  22. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘struct V<Foo, default_foo>’:
prog.cpp:16:30:   required from here
prog.cpp:11:18: error: in-class initialization of static data member ‘const Foo V<Foo, default_foo>::s_default’ of non-literal type
   static const T s_default = F();
                  ^~~~~~~~~
stdout
Standard output is empty