Guest User

Untitled

a guest
Jan 17th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. // in C++03:
  2. // typedef /* compute */ result;
  3. using result = and_<is_integral<T>, not_<is_char<T>>>;
  4.  
  5. // Enforce precondition: every type T must be integral
  6. static_assert( and_<std::is_integral<T>...>::value, "Violation" );
  7.  
  8. template <typename T,
  9. EnableIf<is_scalable<T>, is_something_else<T>>...>
  10. T twice(T t) { return 2*t; }
  11.  
  12. template<typename T>
  13. typename enable_if<
  14. and_<is_scalable<T>, is_something_else<T>>
  15. , T
  16. >::type twice(T t) { return 2*t; }
  17.  
  18. template<typename T>
  19. typename std::enable_if<
  20. is_scalable<T>::value && is_something_else<T>::value
  21. , T
  22. >::type twice(T t) { return 2*t; }
  23.  
  24. // EnableIf alias now accepts non-type template parameters
  25. template<typename T
  26. , EnableIf<is_scalable<T>() && is_something_else<T>()>...>
  27. T twice(T t) { return 2*t; }
  28.  
  29. is_integral<T>::value && !is_char<T>::value
  30.  
  31. template<typename T>
  32. struct is_integral_and_not_char {
  33. static const bool value = is_integral<T>::value && !is_char<T>::value;
  34. };
  35.  
  36. is_integral_and_not_char<T>::value
  37.  
  38. template<typename T>
  39. struct is_integral_and_not_char
  40. : std::integral_constant<bool, std::is_integral<T>::value && !std::is_char<T>::value>
  41. {}
Add Comment
Please, Sign In to add comment