Skip to content
Discussion options

You must be logged in to vote

The Rule of 5 as in (#62)& The Shard Struct
The copy constructor is explicitly deleted (Shard(const Shard &) = delete;). If copying were allowed, you would have two Shard objects holding the exact same file handle (hFile / fd) or memory pointer (tokens). When the first object gets destroyed and runs its destructor (close_mmap), it closes the file and unmaps the memory. The second object is now holding dangling pointers, which will cause a catastrophic segmentation fault or double-free crash when it tries to read the data or destroy itself.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by eamonsippy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants