Skip to content

Function parameters of type const bool should be simply bool #186

@bobhairgrove

Description

@bobhairgrove

In qhexedit.h at lines 346 and 349, member functions are declared like this:

void setHexCaps(const bool isCaps);
//...
void setDynamicBytesPerLine(const bool isDynamic);

The functions are implemented in qhexedit.cpp at lines 317 and 328.

Since the argument is passed by value, it has no effect to declare them const since the function body receives a copy of the argument, anyway. They should be declared simply as bool.

There is an interesting discussion of this practice on StackOverflow. Another (IMHO) excellent discussion by Herb Sutter is available here

Personally, I think that only arguments of pointer or reference type need it. But from reading the discussion, it seems like this is more a matter of philosophy, or (bad?) style with many developers out there who insist on using it.

If it is more for "self-documentation of source code", as some have suggested, what is it supposed to document?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions