auto i = std::equal_range( first, last, val );
でvalが存在しない場合の挙動で
i.first == last && i.second == last
であるのは保証されてますか?