Last active
December 17, 2015 03:49
-
-
Save FrankHB/5546146 to your computer and use it in GitHub Desktop.
A set of "max" templates using parameter pack.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
using namespace std; | |
template<typename T> | |
inline const T& | |
max_xx(const T& x, const T& y) | |
{ | |
return y < x ? x : y; | |
} | |
template<typename T, typename... P> | |
inline const T& | |
max_xx(const T& x, const T& y, const P& ... args) | |
{ | |
return max_xx(max_xx(x, y), args...); | |
} | |
int main() | |
{ | |
cout << max_xx(string("abc"), string("xxx"), string("defz")) << endl; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment