fork download
  1.  
  2. namespace Foo {
  3.  
  4. class Deriv {};
  5. class Another {};
  6.  
  7. template <typename T>
  8. Another operator* ( T x, const Deriv& d ) { return Another();}
  9. }
  10. namespace Bar {
  11. typedef Foo::Deriv MyDeriv;
  12. MyDeriv operator* (float x, const MyDeriv& d);
  13. }
  14.  
  15. namespace Bar {
  16. void f1() {
  17. Bar::MyDeriv a;
  18. Bar::MyDeriv b = 3.f * a;
  19. }
  20. }
  21.  
  22. void f2() {
  23. Bar::MyDeriv a;
  24. Bar::MyDeriv b = 3.f * a;
  25. }
  26.  
  27. int main() {
  28. // your code goes here
  29. return 0;
  30. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'void f2()':
prog.cpp:24:23: error: conversion from 'Foo::Another' to non-scalar type 'Bar::MyDeriv {aka Foo::Deriv}' requested
  Bar::MyDeriv b = 3.f * a;
                       ^
stdout
Standard output is empty