-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue or Design Decision? #17
Comments
Would you expect to have a shallow or a deep copy? |
A shallow copy would hardly be possible reasonably, since the memory is allocated inside the |
Considering this library aims at microcontrollers and memory is a big limitation I would discourage or even disable the whole pass-by-value rather than supporting it via a deep copy. I can already imagine a user invoking a function and ending up with a hardware rest due to memory corruption... I could understand a shallow copy, but that would have other implications in terms of unexpected side effects. |
I'm willing to solve this by disabling the copy constructor and the assignment operator based on the principle a deep copy is too memory expensive: private:
CircularBuffer(const CircularBuffer&); // no implementation
CircularBuffer& operator=(const CircularBuffer&); // no implementation |
A more modern way would be: CircularBuffer(const CircularBuffer&) = delete;
CircularBuffer(CircularBuffer&&) = delete;
CircularBuffer& operator=(const CircularBuffer&) = delete;
CircularBuffer& operator=(CircularBuffer&&) = delete; The visibility shoud probably be |
This makes me feel damn old 👴 |
The dumpBuf_byVal method logs the wrong values. Did you deliberately omit copy and assignment in the code because people probably won't use it, or do you think it's inappropriate to have these methods?
The text was updated successfully, but these errors were encountered: