Advertisement
tinyevil

Untitled

May 17th, 2018
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. - CanDuplicate {dup} (~ has trivial copy constructor)
  2. You can duplicate a value of the type with memcpy.
  3.  
  4. - CanDiscard {disc} (~ has trivial destructor)
  5. You can discard a value of the type (without invoking destructor)
  6.  
  7. - CanRelocate {rel} (does not have a direct analogy)
  8. You can move a value to a new address with memcpy (discarding the old value in the process).
  9.  
  10.  
  11. Some examples:
  12.  
  13. Primitive types are {dup, disc, rel}
  14. Unique ptr is {rel} (cannot be duplicated, must invoke code when discarded)
  15. Shared ptr is {rel} (must invoke code in duplication, must invoke code when discarded)
  16. Vector is {} (cannot be relocated because may hold a pointer to itself as part of SBO)
  17. Event listener {} (must register itself when duplicated, unregister when discarded, and update its registration when relocated)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement