なぜ boost::find_first は、その入力への非定数参照を取るのですか?のコメント 「反復オブジェクトに十分な寿命があることを「証明」するために、呼び出し元が const_iterator テンプレートパラメーターを使用して非 const iterator_range を作成する」ことを提案します。
これは何を意味し、どのようにすればよいですか?
特に、このコードで const-correctness を達成するにはどうすればよいですか?
typedef std::map<int, double> tMyMap;
tMyMap::const_iterator subrange_begin = my_map.lower_bound(123);
tMyMap::const_iterator subrange_end = my_map.upper_bound(456);
// I'd like to return a subrange that can't modify my_map
// but this vomits template errors complaining about const_iterators
return boost::iterator_range<tMyMap::const_iterator>(subrange_begin, subrange_end);