25 throw std::out_of_range(
"median not defined for empty containers");
29 std::nth_element(v.begin(), v.begin() + n / 2, v.end());
33 auto rightElement = v.at(n / 2);
34 std::nth_element(v.begin(), v.begin() + n / 2 - 1, v.end());
35 return (v.at(n / 2 - 1) + rightElement) / 2;
V::value_type median(V v)
Definition: math.h:23