cppcheck 2.17.1 suggests to use const for method init that changes class member:
typedef void (*InitFunc)(void**); template<typename T> class Object { private: T *m_ptr; public: Object() : m_ptr(0) {} ~Object() { if (m_ptr) delete m_ptr; } void init(InitFunc func) { func(reinterpret_cast<void**>(&m_ptr)); } }; template<typename T> void init(void **ptr) { *ptr = new T; }
test\main.cpp:16:7: style: inconclusive: Technically the member function 'Object < int >::init' can be const. [functionConst] void init(InitFunc func) ^
Thanks for reporting. ticket is here: https://trac.cppcheck.net/ticket/13953
Log in to post a comment.
cppcheck 2.17.1 suggests to use const for method init that changes class member:
Thanks for reporting. ticket is here: https://trac.cppcheck.net/ticket/13953
Last edit: CHR 5 days ago