Menu

#4550 Avoid "using" directives in included files

Fixed
Dan Eble
Maintainability
2020-01-24
2015-08-10
Anonymous
No

Originally created by: *anonymous

Originally created by: nine.fie...@gmail.com
Originally owned by: nine.fie...@gmail.com

"using namespace std;" seems to be *everywhere* in Lilypond.  It appears in *.cc files before headers are included.  It appears in header files too.

"using" directives should not be used where they might affect more than the current file.

The patch for this issue will have to wait for a handful of issues that I found along the way to be fixed, but here is the summary:
  * eliminate "using namespace std;"
  * add "std::" to everything in *.hh files (and other included files)
  * add "using std::whatever;" in *.cc files for common types (e.g. string, vector)
  * add "std::" in *.cc files for functions (e.g. swap) and other less common things (e.g. less)

Latest attempt: https://codereview.appspot.com/579240043/
Earlier attempts: https://codereview.appspot.com/254670043/

Related

Issues: #4550
Issues: #4560

Discussion

1 2 > >> (Page 1 of 2)
  • Google Importer

    Google Importer - 2015-08-15

    Originally posted by: nine.fie...@gmail.com

    https://codereview.appspot.com/254670043/

    Labels: -Type-Maintainability Type-Patch Patch-new

     
  • Google Importer

    Google Importer - 2015-08-15

    Originally posted by: pkx1...@gmail.com

    passes make, make check and a full make doc

    Labels: -Patch-new Patch-review

     
  • Google Importer

    Google Importer - 2015-08-16

    Originally posted by: pkx1...@gmail.com

    Patch on countdown for August 20th.

    Labels: -Patch-review Patch-countdown

     
  • Google Importer

    Google Importer - 2015-08-20

    Originally posted by: pkx1...@gmail.com

    Patch counted down - please push

    Labels: -Patch-countdown Patch-push

     
  • Google Importer

    Google Importer - 2015-08-20

    Originally posted by: nine.fie...@gmail.com

    Pushed to staging:

    commit [r59a6d1a06432fc0ca88c3023c646182f389ec1b5]
    Author: Dan Eble <nine.fierce.ballads@gmail.com>
    Date:   Thu Aug 20 19:06:03 2015 -0400

        Issue 4550 (2/2) Avoid "using namespace std;" in included files
       
        These changes are produced by a rather long shell script that is
        posted in the code review for this issue.  Summary:
       
        * remove "using namespace std;" everywhere
        * add "std::" in *.hh and other included files
        * add "std::" to functions and lesser-used types in *.cc files

    commit [rf127e14af04f474d20406ca0e0f76f05061ee103]
    Author: Dan Eble <nine.fierce.ballads@gmail.com>
    Date:   Sat Aug 8 13:11:02 2015 -0400

        Issue 4550 (1/2) Avoid "using namespace std;" in included files
       
        These are manual changes in preparation for an automated removal of
        "using namespace std;".
       
        Mostly these are additions of using-declarations for commonly used
        types and containers (e.g. std::string, std::vector) to *.cc files so
        that they will continue to build after the big removal.

    Labels: -Patch-push Fixed_2_19_26
    Status: Fixed

     

    Related

    Issues: #4550

  • Google Importer

    Google Importer - 2015-08-23

    Originally posted by: dak@gnu.org

    Because of several outstanding issues not caught timely in review and testing,
    reverted with commits
    commit [r24107d843c902a8101fbb696f47bf7538dd4493a]
    Author: David Kastrup <dak@gnu.org>
    Date:   Sun Aug 23 21:59:31 2015 +0200

        Revert "Issue 4550 (1/2) Avoid "using namespace std;" in included files"
       
        This reverts commit [rf127e14af04f474d20406ca0e0f76f05061ee103].

    commit [r207f71b8b2ab9ca550e841615bedce393e652ca6]
    Author: David Kastrup <dak@gnu.org>
    Date:   Sun Aug 23 21:58:47 2015 +0200

        Revert "Issue 4550 (2/2) Avoid "using namespace std;" in included files"
       
        This reverts commit [r59a6d1a06432fc0ca88c3023c646182f389ec1b5].

    Labels: -Type-Patch -Fixed_2_19_26 Type-Maintainability
    Status: Started

     

    Related

    Issues: #4550

  • Dan Eble

    Dan Eble - 2015-09-03
    • Description has changed:

    Diff:

    
    
    • assigned_to: Dan Eble
    • Needs: -->
    • Patch: -->
     
  • Simon Albrecht

    Simon Albrecht - 2015-09-09
     
  • Dan Eble

    Dan Eble - 2015-09-26

    Trying again. The original manual changes (1/2) applied cleanly over the current master and running the same script again (2/2) produced buildable code.

    https://codereview.appspot.com/269000043/

     
  • Dan Eble

    Dan Eble - 2015-09-26
    • Patch: --> new
     
  • Anonymous

    Anonymous - 2015-09-26

    Passes make, make check and a full make doc.

     
  • Anonymous

    Anonymous - 2015-09-26
    • Patch: new --> review
     
  • Anonymous

    Anonymous - 2015-09-29
    • Patch: review --> countdown
     
  • Anonymous

    Anonymous - 2015-09-29

    Patch on countdown for October 2nd.

     
  • Anonymous

    Anonymous - 2015-10-02

    Patch counted down - please push

     
  • Anonymous

    Anonymous - 2015-10-02
    • Patch: countdown --> push
     
  • Dan Eble

    Dan Eble - 2015-10-03

    Pushed to staging. Commit 2/2 didn't rebase cleanly so I discarded the reviewed version and ran the script again.

    commit cb0b407e567feca71cbc5f9479a06b266c69a26c
    Author: Dan Eble nine.fierce.ballads@gmail.com
    Date: Sat Oct 3 12:29:13 2015 -0400

    Issue 4550 (2/2) Avoid "using namespace std;" in included files
    
    These changes are produced by a rather long shell script that is
    posted in the code review for this issue.  Summary:
    
    * remove "using namespace std;" everywhere
    * add "std::" in *.hh and other included files
    * add "std::" to functions and lesser-used types in *.cc files
    

    commit 1de3d397c18622b6061402fef18e625701712bc5
    Author: Dan Eble nine.fierce.ballads@gmail.com
    Date: Sat Aug 8 13:11:02 2015 -0400

    Issue 4550 (1/2) Avoid "using namespace std;" in included files
    
    These are manual changes in preparation for an automated removal of
    "using namespace std;".
    
    Mostly these are additions of using-declarations for commonly used
    types and containers (e.g. std::string, std::vector) to *.cc files so
    that they will continue to build after the big removal.
    
     
  • Dan Eble

    Dan Eble - 2015-10-03
    • labels: --> Fixed_2_19_29
    • Patch: push -->
     
  • Trevor Daniels

    Trevor Daniels - 2015-10-03
    • status: Started --> Fixed
     
  • David Kastrup

    David Kastrup - 2015-10-18
    • labels: Fixed_2_19_29 -->
    • status: Fixed --> Started
    • Patch: --> needs_work
     
  • David Kastrup

    David Kastrup - 2015-10-18

    Reverted again since it still fails to convert isinf to std::isinf, resulting in a failed build as in the previous iteration.

    commit 626874c8eecfbeb04ca8ffec3fb78da48859b42f
    Author: David Kastrup dak@gnu.org
    Date: Sun Oct 18 15:24:26 2015 +0200

    Revert "Issue 4550 (1/2) Avoid "using namespace std;" in included files"
    
    This reverts commit 1de3d397c18622b6061402fef18e625701712bc5.
    

    commit 5af7cd44435fd26fade6e700a3912630e1553a87
    Author: David Kastrup dak@gnu.org
    Date: Sun Oct 18 15:22:53 2015 +0200

    Revert "Issue 4550 (2/2) Avoid "using namespace std;" in included files"
    
    This reverts commit cb0b407e567feca71cbc5f9479a06b266c69a26c.
    
    Conflicts:
        lily/include/slur-proto-engraver.hh
        lily/scm-hash.cc
    
     
  • Dan Eble

    Dan Eble - 2020-01-22

    Issue 4550: Avoid "using namespace std;" in included files

    https://codereview.appspot.com/579240043

     
  • Dan Eble

    Dan Eble - 2020-01-22
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -12,3 +12,6 @@
     &amp;nbsp; \* add &#34;std::&#34; to everything in \*.hh files \(and other included files\)
     &amp;nbsp; \* add &#34;using std::whatever;&#34; in \*.cc files for common types \(e.g. string, vector\)
     &amp;nbsp; \* add &#34;std::&#34; in \*.cc files for functions \(e.g. swap\) and other less common things \(e.g. less\)
    +
    +Latest attempt: https://codereview.appspot.com/579240043/
    +Earlier attempts: &lt;strike&gt; https://codereview.appspot.com/254670043/ &lt;/strike&gt;
    
    • Needs: -->
    • Type: --> Maintainability
     
  • Anonymous

    Anonymous - 2020-01-22
    • Patch: new --> review
     
  • Anonymous

    Anonymous - 2020-01-22

    Passes make, make check and a full make doc.

     
1 2 > >> (Page 1 of 2)
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.