fork download
  1. #include <type_traits>
  2.  
  3. template<typename U>
  4. struct Explicit
  5. {
  6. bool value;
  7. template<typename T = U, typename = std::enable_if_t<std::is_same<std::decay_t<T>, U>::value>>
  8. Explicit(T&& value) : value(value) { }
  9. operator U() { return value; }
  10. };
  11.  
  12. void Foo(Explicit<bool> arg1 = false, int arg2 = 10, int arg3 = 20) { }
  13.  
  14. int main(int argc, char ** argv)
  15. {
  16. int x = 40, y = 50;
  17. Foo();
  18. Foo(true, x, y);
  19. Foo((bool)x, y);
  20. }
Success #stdin #stdout 0s 3136KB
stdin
Standard input is empty
stdout
Standard output is empty