Angus Leeming <[EMAIL PROTECTED]> writes:
| On Tuesday 05 November 2002 12:24 pm, Lars Gullik Bj�nnes wrote:
>> Angus Leeming <[EMAIL PROTECTED]> writes:
>> | On Tuesday 05 November 2002 12:08 pm, Lars Gullik Bj�nnes wrote:
>> >> Angus Leeming <[EMAIL PROTECTED]> writes:
>> >> | Doesn't fix getVectorFromString, but does reduce cpu usage thereafter.
>> >> | Ok to apply?
>> >>
>> >> yes.
>> |
>> | Thanks, but since I had the file open...
>> |
>> | I think that this is wrong:
>> |
>> | // A functor for use with std::sort, leading to case insensitive sorting
>> | struct compareNoCase: public std::binary_function<string, string, bool>
>> | {
>> | bool operator()(string const & s1, string const & s2) const {
>> | return compare_ascii_no_case(s1, s2) < 0;
>> | }
>> | };
>> |
>> | vector<string> const getKeys(InfoMap const & map)
>> | {
>> | vector<string> bibkeys = ...;
>> | sort(bibkeys.begin(), bibkeys.end(), compareNoCase());
>> | }
>> |
>> | Shouldn't sort use compare_ascii_no_case directly here? As written the
>> | code is using (a == b), but sort uses (a < b) doesn't it?
>>
>> I think the code is right as it is.
>>
>> sort would try to use std::less<string>(a, b) which would return
>> bool(a < b)
>
| Indeed. However, does the functor need to derive from std::binary_function?
| It compiles fine without which, if I read my "Effective STL" correctly, means
| that it'll also work ok.
let's say that it is nice to do so, and some stdlibs will have checks
to see if you do. f.ex from stdlibc++:
// concept requirements
__glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIter>)
__glibcpp_function_requires(_BinaryPredicateConcept<_Compare, _ValueType,
_ValueType>)
--
Lgb