#include <folly/Likely.h>
#include <folly/Malloc.h>
#include <folly/Traits.h>
+#include <folly/portability/BitsFunctexcept.h>
#include <boost/operators.hpp>
static void
S_uninitialized_copy_bits(T* dest, const T* first, const T* last) {
- std::memcpy((void*)dest, (void*)first, (last - first) * sizeof(T));
+ if (last != first) {
+ std::memcpy((void*)dest, (void*)first, (last - first) * sizeof(T));
+ }
}
static void
std::move_iterator<T*> last) {
T* bFirst = first.base();
T* bLast = last.base();
- std::memcpy((void*)dest, (void*)bFirst, (bLast - bFirst) * sizeof(T));
+ if (bLast != bFirst) {
+ std::memcpy((void*)dest, (void*)bFirst, (bLast - bFirst) * sizeof(T));
+ }
}
template <typename It>
}
void relocate_move_or_memcpy(T* dest, T* first, T* last, std::true_type) {
- std::memcpy((void*)dest, (void*)first, (last - first) * sizeof(T));
+ if (first != nullptr) {
+ std::memcpy((void*)dest, (void*)first, (last - first) * sizeof(T));
+ }
}
void relocate_move_or_memcpy(T* dest, T* first, T* last, std::false_type) {
}
const_reference at(size_type n) const {
if (UNLIKELY(n >= size())) {
- throw std::out_of_range("fbvector: index is greater than size.");
+ std::__throw_out_of_range("fbvector: index is greater than size.");
}
return (*this)[n];
}
// fbvector grows differently on two counts:
//
// (1) initial size
- // Instead of grwoing to size 1 from empty, and fbvector allocates at
- // least 64 bytes. You may still use reserve to reserve a lesser amount
- // of memory.
+ // Instead of growing to size 1 from empty, fbvector allocates at least
+ // 64 bytes. You may still use reserve to reserve a lesser amount of
+ // memory.
// (2) 1.5x
// For medium-sized vectors, the growth strategy is 1.5x. See the docs
// for details.