Commit 798c93a2 authored by Mark Santaniello's avatar Mark Santaniello Committed by Facebook GitHub Bot

Auto-reserve any base of random access iterator

Summary:
Rather than demanding precisely a random access iterator, allow any base of it.

https://en.cppreference.com/w/cpp/iterator/iterator_tags

Reviewed By: yfeldblum, Gownta

Differential Revision: D33039206

fbshipit-source-id: 7b62c03704a70340a605df4d7885dce29726d8ee
parent 8597900f
...@@ -329,9 +329,9 @@ class F14BasicMap { ...@@ -329,9 +329,9 @@ class F14BasicMap {
// is easy to disable at a particular call site by asking for an // is easy to disable at a particular call site by asking for an
// initialCapacity of 1. // initialCapacity of 1.
bool autoReserve = bool autoReserve =
std::is_same< std::is_base_of<
typename std::iterator_traits<InputIt>::iterator_category, std::random_access_iterator_tag,
std::random_access_iterator_tag>::value && typename std::iterator_traits<InputIt>::iterator_category>::value &&
initialCapacity == 0; initialCapacity == 0;
bulkInsert(first, last, autoReserve); bulkInsert(first, last, autoReserve);
} }
...@@ -343,9 +343,9 @@ class F14BasicMap { ...@@ -343,9 +343,9 @@ class F14BasicMap {
// ourself to situations that mimic bulk construction without an // ourself to situations that mimic bulk construction without an
// explicit initialCapacity. // explicit initialCapacity.
bool autoReserve = bool autoReserve =
std::is_same< std::is_base_of<
typename std::iterator_traits<InputIt>::iterator_category, std::random_access_iterator_tag,
std::random_access_iterator_tag>::value && typename std::iterator_traits<InputIt>::iterator_category>::value &&
bucket_count() == 0; bucket_count() == 0;
bulkInsert(first, last, autoReserve); bulkInsert(first, last, autoReserve);
} }
......
...@@ -285,9 +285,9 @@ class F14BasicSet { ...@@ -285,9 +285,9 @@ class F14BasicSet {
// is easy to disable at a particular call site by asking for an // is easy to disable at a particular call site by asking for an
// initialCapacity of 1. // initialCapacity of 1.
bool autoReserve = bool autoReserve =
std::is_same< std::is_base_of<
typename std::iterator_traits<InputIt>::iterator_category, std::random_access_iterator_tag,
std::random_access_iterator_tag>::value && typename std::iterator_traits<InputIt>::iterator_category>::value &&
initialCapacity == 0; initialCapacity == 0;
bulkInsert(first, last, autoReserve); bulkInsert(first, last, autoReserve);
} }
...@@ -299,9 +299,9 @@ class F14BasicSet { ...@@ -299,9 +299,9 @@ class F14BasicSet {
// ourself to situations that mimic bulk construction without an // ourself to situations that mimic bulk construction without an
// explicit initialCapacity. // explicit initialCapacity.
bool autoReserve = bool autoReserve =
std::is_same< std::is_base_of<
typename std::iterator_traits<InputIt>::iterator_category, std::random_access_iterator_tag,
std::random_access_iterator_tag>::value && typename std::iterator_traits<InputIt>::iterator_category>::value &&
bucket_count() == 0; bucket_count() == 0;
bulkInsert(first, last, autoReserve); bulkInsert(first, last, autoReserve);
} }
......
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