fork(1) download
  1. #include <stdio.h>
  2. #include <initializer_list>
  3.  
  4. struct A{
  5. void operator=(std::initializer_list<int> a){printf("int[%zu]:",a.size());for (auto x:a) printf(" %d",x); printf("\n");}
  6. void operator=(float a){printf("float: %.1f\n",a);}
  7. };
  8.  
  9. struct B:A{
  10. using A::operator=;
  11. template <typename T>
  12. void operator=(T x){
  13. printf("+");
  14. A::operator=(x);
  15. }
  16. //void operator=(std::initializer_list<int>);
  17. //void operator=(float);
  18. };
  19.  
  20.  
  21. int main() {
  22.  
  23. A a;
  24. a={1,2,5};
  25. a=5.6;
  26.  
  27. B b;
  28. b={1,5,6};
  29. b=4.7;
  30.  
  31. }
  32.  
Success #stdin #stdout 0s 4876KB
stdin
Standard input is empty
stdout
int[3]: 1 2 5
float: 5.6
int[3]: 1 5 6
+float: 4.7