Skip to content

enh: using namespace std in header #13

@gabywh

Description

@gabywh

Enhancement:

I appreciate in a 2-file project it's probably not so much an issue but you really shouldn't be putting using namespace std in a header file as this forcibly includes the whole std namespace for any implementation code that wishes to use the bloom.hpp header.

Avoiding placing using namespace std (or indeed any using namespace X) in a header is mentioned in so many places I forget where - maybe Exceptional C++ - / Sutter would be one, Scott Meyers' Effective STL almost certainly another (Bjarne Stroustrup C++ Prog Lang another?) - but one ref I did just find an old classic from Sutter's GOTW: http://gotw.ca/gotw/053.htm see Section 2, Guideline #1:

  1. Using directives should be avoided entirely, especially in header files

Sutter also makes the distinction here - as I did above - in a footnote that this guideline is valid for shared header files (i.e. used by more than one cpp) : http://gotw.ca/gotw/053.htm#1 so you could argue "no change here" since only one cpp, but then you could also argue that it is simply poor style - which I why I label this as an enhancement

BTW: nothing against using namespace std in your cpp, should you wish to do so - so this is probably a one-line change: remove using namespace std from the header and add it to the cpp. Depending on where you place the using in your cpp, you may need to fully qualify any STL types in the header file.

I can fork this repo and supply a PR with change if you accept this as an (enhancement) issue.

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