#ifndef FOLLY_SMALL_VECTOR_H_
#define FOLLY_SMALL_VECTOR_H_
-#include "Portability.h"
+#include <folly/Portability.h>
#include <stdexcept>
#include <cstdlib>
#include <boost/mpl/count.hpp>
#include <boost/mpl/max.hpp>
-#include "folly/Malloc.h"
+#include <folly/Malloc.h>
#if defined(__GNUC__) && FOLLY_X64
-# include "folly/SmallLocks.h"
+# include <folly/SmallLocks.h>
# define FB_PACK_ATTR FOLLY_PACK_ATTR
# define FB_PACK_PUSH FOLLY_PACK_PUSH
# define FB_PACK_POP FOLLY_PACK_POP
try {
std::uninitialized_copy(o.begin(), o.end(), begin());
} catch (...) {
- if (this->isExtern()) u.freeHeap();
+ if (this->isExtern()) {
+ u.freeHeap();
+ }
throw;
}
this->setSize(n);
}
- small_vector(small_vector&& o) {
+ small_vector(small_vector&& o)
+ noexcept(std::is_nothrow_move_constructible<Value>::value) {
if (o.isExtern()) {
swap(o);
} else {
auto distance = std::distance(first, last);
makeSize(distance);
this->setSize(distance);
-
- detail::populateMemForward(data(), distance,
- [&] (void* p) { new (p) value_type(*first++); }
- );
+ try {
+ detail::populateMemForward(data(), distance,
+ [&] (void* p) { new (p) value_type(*first++); }
+ );
+ } catch (...) {
+ if (this->isExtern()) {
+ u.freeHeap();
+ }
+ throw;
+ }
}
void doConstruct(size_type n, value_type const& val) {
makeSize(n);
this->setSize(n);
- detail::populateMemForward(data(), n,
- [&] (void* p) { new (p) value_type(val); }
- );
+ try {
+ detail::populateMemForward(data(), n,
+ [&] (void* p) { new (p) value_type(val); }
+ );
+ } catch (...) {
+ if (this->isExtern()) {
+ u.freeHeap();
+ }
+ throw;
+ }
}
// The true_type means we should forward to the size_t,value_type