min_element内部では
min_element
if (comp(*first, *smallest)) {
smallest = first;
}
なので,
*firstが0のときにfalse,
*secondが0のときにtrueを返せばOK.
min.cpp
#include <iostream>
#include <vector>
#include <algorithm>
using std::vector;
using std::cout;
using std::endl;
int main() {
vector<int> a = {0, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 0};
auto min = min_element(a.begin(), a.end(), [](int a, int b) {
return (a == 0) ? false : (b == 0) || a < b;
});
cout << *min << endl;
return 0;
}