fork download
  1. #include <type_traits>
  2.  
  3. template<typename T>
  4. struct identity
  5. {
  6. using type = T;
  7. };
  8.  
  9. template<template<typename...> class F , typename... ARGS>
  10. struct lazy
  11. {};
  12.  
  13. namespace impl
  14. {
  15. template<typename L , typename... ARGS>
  16. struct lazy_instance;
  17.  
  18. template<template<typename...> class F , typename... ARGS , typename... IARGS>
  19. struct lazy_instance<lazy<F,ARGS...>,IARGS...> : public identity<F<ARGS...>>
  20. {};
  21. }
  22.  
  23. template<typename L , typename... ARGS>
  24. using lazy_instance = typename impl::lazy_instance<L,ARGS...>::type;
  25.  
  26.  
  27.  
  28. template<typename T>
  29. struct foo
  30. {
  31. static_assert( sizeof(T) != sizeof(T) , "ERROR, USE INT" );
  32. };
  33.  
  34. template<>
  35. struct foo<int>
  36. {};
  37.  
  38.  
  39. using ok = lazy_instance<typename std::conditional<false,
  40. lazy<foo,int>,
  41. lazy<foo,bool>
  42. >::type
  43. >;
  44.  
  45. static_assert( std::is_same<ok,foo<bool>>::value , "Mmmmm..." );
  46.  
  47. int main(){}
Success #stdin #stdout 0s 3292KB
stdin
Standard input is empty
stdout
Standard output is empty