#include <math.h> double dist(double i1, double i2) { return fabs(i1-i2); } int main() { vector<double> iv; iv.push_back(1); iv.push_back(2); iv.push_back(3); iv.push_back(4.9); iv.push_back(6); iv.push_back(7); iv.push_back(8); double i = *min_element( iv.begin(), iv.end(), bind( less<double>(), bind(&dist,_1,5.0), bind(&dist,_2,5.0) ) ); cout<<"min is "<<i<<endl;