Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- template<class T, class... R>
- struct calc_min {
- T operator()(T const &, T const &...) const;
- };
- template<class T>
- struct calc_min<T> {
- T operator()(T const &x) const
- { return x; }
- };
- template<class T, class... R>
- struct calc_min<T, T, R...> {
- T operator()(T const &a, T const &b, R const &... rest) const
- { return calc_min<T, R...>()(a < b ? a : b, rest...); }
- };
- template<class T, class... R>
- T super_min(T const &first, R const &... args)
- { return calc_min<T, R...>()(first, args...); }
- int main() {
- std::cout << super_min(1, 4, 10, 100) << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement