fork download
  1. #include <memory>
  2. #include <utility>
  3.  
  4. struct IMoo {};
  5. struct MooA : public IMoo {};
  6. struct MooB : public IMoo {};
  7.  
  8. template<typename T, typename... Args>
  9. std::shared_ptr<IMoo> make_shared_moo(Args&&... args) {
  10. return std::make_shared<T>(std::forward<Args>(args)...);
  11. }
  12.  
  13. class Foo
  14. {
  15. public:
  16. Foo() : m_moo(false ? make_shared_moo<MooA>() : make_shared_moo<MooB>())
  17. {
  18. }
  19. private:
  20. std::shared_ptr<IMoo> m_moo;
  21. };
  22.  
  23.  
  24. int main() {
  25. }
Success #stdin #stdout 0s 3292KB
stdin
Standard input is empty
stdout
Standard output is empty