Skip to content

Remove superfluous const parameters from function declarations #105

Description

@JuanDiegoMontoya

For non-reference, non-pointer function prototype parameters, const is superfluous and has no effect. It only serves to clutter the API and does not provide any guarantee to the caller. See this SO answer for more info.

Suggestion: remove const from non-reference, non-pointer-like parameters in function declarations, and keep them in function definitions to maintain const-correctness where it matters, for example:

class DearImGuiApplication final : public Application
{
public:
    ...
    void OnResize(
        int32_t width,
        int32_t height) override;
    ...
};

void DearImGuiApplication::OnResize(
    const int32_t width,
    const int32_t height)
{
    ...
}

The other place I have noticed this issue is with the std::string_view parameter of Application's (and its derivatives') constructor.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions