Q:

C++ find highest element in array that isant a particular value

I am using some data that uses some an extremely high value as an error code. I am currently using std max element, is there a way to do this ignoring a particular value?. eg max element that isant a particular number. 

A:

So, let's use a custom comparator as part of the call to std::max_element. We'll just make sure that if we see the error code, then we'll make that smaller than all other elements.
auto maxElement = std::max_element(std::begin(container), std::end(container), [](T const & lhs, T const & rhs) -> bool {
    if (rhs == error_code)
         return false;
    if (lhs == error_code)
         return true;
    return lhs < rhs;
}

