template <class Iterator>
int distance_if_multipass(Iterator first, Iterator last) {
typedef typename std::iterator_traits<Iterator>::iterator_category categ;
- if (std::is_same<categ,std::input_iterator_tag>::value)
+ if (std::is_same<categ, std::input_iterator_tag>::value) {
return -1;
+ }
return std::distance(first, last);
}
if (!std::is_sorted(middle, cont.end(), cmp)) {
std::sort(middle, cont.end(), cmp);
}
- if (middle != cont.begin() && cmp(*middle, *(middle - 1))) {
+ if (middle != cont.begin() && !cmp(*(middle - 1), *middle)) {
std::inplace_merge(cont.begin(), middle, cont.end(), cmp);
cont.erase(
std::unique(
iterator find(const key_type& key) {
iterator it = lower_bound(key);
- if (it == end() || !key_comp()(key, *it))
+ if (it == end() || !key_comp()(key, *it)) {
return it;
+ }
return end();
}
const_iterator find(const key_type& key) const {
const_iterator it = lower_bound(key);
- if (it == end() || !key_comp()(key, *it))
+ if (it == end() || !key_comp()(key, *it)) {
return it;
+ }
return end();
}
iterator find(const key_type& key) {
iterator it = lower_bound(key);
- if (it == end() || !key_comp()(key, it->first))
+ if (it == end() || !key_comp()(key, it->first)) {
return it;
+ }
return end();
}
const_iterator find(const key_type& key) const {
const_iterator it = lower_bound(key);
- if (it == end() || !key_comp()(key, it->first))
+ if (it == end() || !key_comp()(key, it->first)) {
return it;
+ }
return end();
}