fork(4) download
  1. #include <type_traits>
  2.  
  3. template<typename T>
  4. struct identity { using type = T; };
  5.  
  6. template<typename T>
  7. using try_make_signed =
  8. typename std::conditional<
  9. std::is_integral<T>::value,
  10. std::make_signed<T>,
  11. identity<T>
  12. >::type;
  13.  
  14. int main()
  15. {
  16. static_assert(std::is_same<try_make_signed<unsigned int>::type, int>::value, "!");
  17. static_assert(std::is_same<try_make_signed<double>::type, double>::value, "!");
  18. }
  19.  
Success #stdin #stdout 0s 2892KB
stdin
Standard input is empty
stdout
Standard output is empty