fork download
  1. #include <iostream>
  2. struct A {
  3. A(){}
  4. A(const A &){ std::cout << "IN A" << std::endl; }
  5. };
  6.  
  7. struct B : public A{
  8. template<typename ...Args,
  9. typename = typename std::enable_if
  10. <
  11. std::is_constructible<A, Args...>::value
  12. >::type>
  13. B(Args &&...args)
  14. : A(std::forward<Args>(args)...) {}
  15. };
  16. template<>
  17. inline B::B(const A &a):A(a){ std::cout << "IN B-A" << std::endl; }
  18. template<>
  19. inline B::B(const B &b):A(b){ std::cout << "IN B-B" << std::endl; }
  20.  
  21. int main(){
  22. A a;
  23. B b(a);
  24. B b1(b);
  25. return 0;
  26. }
Success #stdin #stdout 0s 2884KB
stdin
Standard input is empty
stdout
IN A
IN A