#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
struct Size {
int width, height;
};
int main()
{
std::vector<Size> sizes = { {4, 1}, {2, 3}, {1, 2} };
decltype(sizes)::iterator minEl, maxEl;
std::tie(minEl, maxEl) = std::minmax_element(begin(sizes), end(sizes),
[] (Size const& s1, Size const& s2)
{
return s1.width < s2.width;
});
std::cout << "Minimum (based on width): "
<< minEl->width << "," << minEl->height << std::endl;
std::cout << "Maximum (based on width): "
<< maxEl->width << "," << maxEl->height << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8dHVwbGU+CiNpbmNsdWRlIDxhbGdvcml0aG0+CgpzdHJ1Y3QgU2l6ZSB7CiAgICBpbnQgd2lkdGgsIGhlaWdodDsKfTsKCmludCBtYWluKCkKewogICAgc3RkOjp2ZWN0b3I8U2l6ZT4gc2l6ZXMgPSB7IHs0LCAxfSwgezIsIDN9LCB7MSwgMn0gfTsKCiAgICBkZWNsdHlwZShzaXplcyk6Oml0ZXJhdG9yIG1pbkVsLCBtYXhFbDsKICAgIHN0ZDo6dGllKG1pbkVsLCBtYXhFbCkgPSBzdGQ6Om1pbm1heF9lbGVtZW50KGJlZ2luKHNpemVzKSwgZW5kKHNpemVzKSwKICAgICAgICBbXSAoU2l6ZSBjb25zdCYgczEsIFNpemUgY29uc3QmIHMyKQogICAgICAgIHsKICAgICAgICAgICAgcmV0dXJuIHMxLndpZHRoIDwgczIud2lkdGg7CiAgICAgICAgfSk7CgogICAgc3RkOjpjb3V0IDw8ICJNaW5pbXVtIChiYXNlZCBvbiB3aWR0aCk6ICIKICAgICAgICA8PCBtaW5FbC0+d2lkdGggPDwgIiwiIDw8IG1pbkVsLT5oZWlnaHQgPDwgc3RkOjplbmRsOwoKICAgIHN0ZDo6Y291dCA8PCAiTWF4aW11bSAoYmFzZWQgb24gd2lkdGgpOiAiICAKICAgICAgICA8PCBtYXhFbC0+d2lkdGggPDwgIiwiIDw8IG1heEVsLT5oZWlnaHQgPDwgc3RkOjplbmRsOwp9Cg==