fork download
  1. #include <type_traits>
  2.  
  3. template <typename>
  4. struct dependent_false { enum { value = false }; };
  5.  
  6. template <typename T>
  7. struct foo : std::false_type { static_assert(dependent_false<T>::value, "Not lazy!"); };
  8. template <>
  9. struct foo<int> : std::true_type {};
  10.  
  11. template <typename T>
  12. struct bar : foo<T> {};
  13.  
  14. template<typename... T>
  15. struct And : std::true_type {};
  16.  
  17. template<typename T, typename... Ts>
  18. struct And<T, Ts...>: std::integral_constant<bool, T::value && And<Ts...>::value> {};
  19.  
  20. int main() {
  21. return And<std::false_type, bar<double>>::value;
  22. }
  23.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of 'foo<double>':
prog.cpp:12:21:   instantiated from 'bar<double>'
prog.cpp:18:83:   instantiated from 'And<bar<double> >'
prog.cpp:18:83:   instantiated from 'And<std::integral_constant<bool, false>, bar<double> >'
prog.cpp:21:45:   instantiated from here
prog.cpp:7:32: error: static assertion failed: "Not lazy!"
stdout
Standard output is empty