Commit 81b08b7e authored by Xavier Deguillard's avatar Xavier Deguillard Committed by Facebook GitHub Bot

Do not use int as the return type for distance_if_multipass

Summary:
The MSVC compiler complains about a potential lossy conversion happening,
which feels mostly right due to Iterators being potentially far apart.

Reviewed By: yfeldblum

Differential Revision: D21280438

fbshipit-source-id: 8fcb18d865688aa1fae869a41256ad3dc3ad2a97
parent c9f2df1b
......@@ -125,7 +125,9 @@ struct growth_policy_wrapper<void> {
* -1.
*/
template <class Iterator>
int distance_if_multipass(Iterator first, Iterator last) {
typename std::iterator_traits<Iterator>::difference_type 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) {
return -1;
......@@ -176,7 +178,7 @@ void bulk_insert(
auto const& cmp(sorted.value_comp());
int const d = distance_if_multipass(first, last);
auto const d = distance_if_multipass(first, last);
if (d != -1) {
cont.reserve(cont.size() + d);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment