Guest User

Untitled

a guest
Mar 14th, 2023
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1.   void M_relocate(T* newB) {
  2.     relocate_move(newB, impl_.b_, impl_.e_);
  3.     relocate_done(newB, impl_.b_, impl_.e_);
  4.   }
  5.  
  6.   void relocate_move_or_memcpy(T* dest, T* first, T* last, std::true_type) {
  7.     if (first != nullptr) {
  8.       std::memcpy((void*)dest, (void*)first, (last - first) * sizeof(T));
  9.     }
  10.   }
  11.  
  12.   void relocate_done(T* /*dest*/, T* first, T* last) noexcept {
  13.     if (folly::IsRelocatable<T>::value && usingStdAllocator) {
  14.       // used memcpy; data has been relocated, do not call destructor
  15.     } else {
  16.       D_destroy_range_a(first, last);
  17.     }
  18.   }
  19.  
  20.  
  21. ^^^^^^^^^^^^^ If `T = std::unique_pointer<int>`, how will the original objects know to not deallocate the `int`s when they go out of scope?
  22.  
  23. (Code taken from: https://github.com/facebook/folly/blob/5445a6d9761fb511cbd0add6e31b84908b387948/folly/FBVector.h#L658)
Advertisement
Add Comment
Please, Sign In to add comment