#include <iostream>
#include <vector>
#include <algorithm>


struct Struct
{
	Struct(long value) :
		_value_1(value),
		_value_2(10 - value)
	{}

	long _value_1;
	long _value_2;
};

template <typename StructureType, 
			typename MemberType, 
			MemberType StructureType::*member>
bool comparator(const StructureType& the_first, const StructureType& the_second)
{
	return the_first.*member < the_second.*member;
}

int main(int argc, char const *argv[])
{
	
	std::vector<Struct> vect = { 1, 2, 3, 4, 5 };
	auto result_1 = 
		std::max_element(std::begin(vect), std::end(vect), 
		                 comparator<Struct, long, &Struct::_value_1>);
	auto result_2 = 
		std::max_element(std::begin(vect), std::end(vect), 
		                 comparator<Struct, long, &Struct::_value_2>);
	
	std::cout 
		<< "Result 1:" << result_1->_value_1 << std::endl
		<< "Result 2:" << result_2->_value_2 << std::endl;

	return 0;
}