fork download
  1. #include <string>
  2. #include <typeindex>
  3. #include <iostream>
  4.  
  5. struct DummyProduction {
  6. };
  7.  
  8. struct Dep {
  9. };
  10.  
  11. struct Pro {
  12. };
  13.  
  14. class ModuleBase {
  15. };
  16.  
  17. template<typename Production = DummyProduction>
  18. class Provider {
  19. public:
  20. template<typename... Dependencies>
  21. Provider(ModuleBase& module, Dependencies... args)
  22. {
  23. std::cout << "Provider called!" << std::endl;
  24. }
  25. Provider(const Provider&) = delete;
  26. };
  27.  
  28. class TargetController : public ModuleBase,
  29. public Provider<Pro>,
  30. public Provider<>
  31. {
  32. public:
  33. TargetController();
  34. private:
  35. Dep p;
  36. };
  37.  
  38. TargetController::TargetController() :
  39. ModuleBase(),
  40. Provider<Pro>(*this, &p),
  41. Provider<>(*this),
  42. p()
  43. {
  44. }
  45.  
  46. int main()
  47. {
  48. TargetController x;
  49. return 0;
  50. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In constructor 'TargetController::TargetController()':
prog.cpp:42:5: error: use of deleted function 'Provider<Production>::Provider(const Provider<Production>&) [with Production = DummyProduction]'
   p()
     ^
prog.cpp:25:3: note: declared here
   Provider(const Provider&) = delete;
   ^
stdout
Standard output is empty