Menu

[Feature Request] Find overloaded functions that could be turned into default arguments

2024-10-12
2024-10-15
  • Tobias Markus

    Tobias Markus - 2024-10-12

    Assuming the following declaration

    Vector
    GameSession::get_fade_point() const
    {
      return get_fade_point(Vector(0.0f, 0.0f));
    }
    
    Vector
    GameSession::get_fade_point(const Vector& position) const
    {
           // Some code here     
    }
    

    What we can see is that these two function definitions can be rewritten to use default arguments as follows:

    Vector
    GameSession::get_fade_point(const Vector& position = Vector(0.0f, 0.0f)) const
    {
           // Some code here     
    }
    

    I wonder if it makes sense for cppcheck to add such a check.

     
  • Oleksandr Labetskyi

    Thank you for the report. You can find the ticket here

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.