Skip to content

guideline for preferring free functions over member functions #1150

@beinhaerter

Description

@beinhaerter

CppCon 2017: Klaus Iglberger “Free Your Functions!” gives good reason why one should prefer free functions over member functions. Like for example std::begin(x) is better than x.begin(), std::size(x) is better than x.size(). Also functions like swap should be implemented as free functions and not as member functions (see Specializations under http://en.cppreference.com/w/cpp/algorithm/swap).

Looking at the samples in the guidelines I see that there is no consistent style. Sometimes the free functions are used, sometimes the member functions are used. In my opinion it would be a nice enhancement to have a consistent style and to have this backed by a guideline.

If there is interest I could prepare a PR at least for making the samples consistent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions