In C++, you may forget to refer to objects with heavy generation and release, such as std::set, when passing them to a function with const.Do you have any existing code review tools or compiler options to check this (now using GCC 7.3)?
Even if I'm careful, I'm in trouble because code reviews often warn me.
Make sure you turn off the copy constructor (and substitute operator).
For example, if you do not want to copy std::set<int>
, define the class that inherited std::set<int>
and clear the copy constructor and operator=
.
class IntSet:public std::set<int>{
public:
IntSet();
// Define other constructors as needed
IntSet(const IntSet&) = delete;
IntSet&operator=(const IntSet&)=delete;
};
This causes a compilation error if a copy of an instance is required for an argument that is not a reference.
If you need to copy intentionally, add a member function such as IntSetclone()const
.
568 Who developed the "avformat-59.dll" that comes with FFmpeg?
601 GDB gets version error when attempting to debug with the Presense SDK (IDE)
568 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
894 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.