Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. template<class T, class... R>
  4. struct calc_min {
  5.     T operator()(T const &, T const &...) const;
  6. };
  7.  
  8. template<class T>
  9. struct calc_min<T> {
  10.     T operator()(T const &x) const
  11.     { return x; }
  12. };
  13.  
  14. template<class T, class... R>
  15. struct calc_min<T, T, R...> {
  16.     T operator()(T const &a, T const &b, R const &... rest) const
  17.     { return calc_min<T, R...>()(a < b ? a : b, rest...); }
  18. };
  19.  
  20. template<class T, class... R>
  21. T super_min(T const &first, R const &... args)
  22. { return calc_min<T, R...>()(first, args...); }
  23.  
  24. int main() {
  25.     std::cout << super_min(1, 4, 10, 100) << '\n';
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement