Lars Gullik Bjønnes wrote: > Some stuff are different in this patch (but not that much...), most > notably is the use of boost::indirect_iterator to get rid of the > bind(&Format::name, bind(operator->, _1)) > construct.
Once I found the code... very nice. > btw. AFAIK the boost iterator adaptors will also be part of tr1. > after I found the base() member function they were easy to use. Sorry to drop a spanner in your well-oiled machine, but I really must point out that boost::function introduces an indirection equivalent to a virtual function call. Thus a change like this which affects the inner loop is likely to introduce a significant performance hit. The struct solution will be optimized away entirely. -// namespace { -struct compare_tags { - // used by lower_bound, sort and sorted - inline - int operator()(keyword_item const & a, keyword_item const & b) const { - // we use the ascii version, because in turkish, 'i' - // is not the lowercase version of 'I', and thus - // turkish locale breaks parsing of tags. - return compare_ascii_no_case(a.tag, b.tag) < 0; - } -}; -// } // end of anon namespace +namespace { + +boost::function<bool(keyword_item const &, keyword_item const &)> +compare_tags() +{ + return bind(less<int>(), + bind(compare_ascii_no_case, + bind(&keyword_item::tag, _1), + bind(&keyword_item::tag, _2)), + 0); +} + + +} // end of anon namespace -- Angus