Changeset 51929 in webkit


Ignore:
Timestamp:
Dec 9, 2009 3:08:44 PM (14 years ago)
Author:
eric@webkit.org
Message:

2009-12-09 Chris Jerdonek <chris.jerdonek@gmail.com>

Reviewed by Darin Adler.

Added the "using std::foo" rule to the coding style guidelines.

https://bugs.webkit.org/show_bug.cgi?id=32301

Added to the coding style guidelines the "using std::foo" rule
checked by the check-webkit-style script. Also clarified the
"using" statement guidelines that apply to implementation files.

  • coding/coding-style.html:
Location:
trunk/WebKitSite
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitSite/ChangeLog

    r51733 r51929  
     12009-12-09  Chris Jerdonek  <chris.jerdonek@gmail.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Added the "using std::foo" rule to the coding style guidelines.
     6       
     7        https://bugs.webkit.org/show_bug.cgi?id=32301
     8       
     9        Added to the coding style guidelines the "using std::foo" rule
     10        checked by the check-webkit-style script.  Also clarified the
     11        "using" statement guidelines that apply to implementation files.
     12
     13        * coding/coding-style.html:
     14
    1152009-12-05  Chris Jerdonek  <chris.jerdonek@gmail.com>
    216
  • trunk/WebKitSite/coding/coding-style.html

    r51733 r51929  
    710710<ol>
    711711
    712 <li>In header files, do not use "using" statements in global or
    713 "namespace" scope.
     712<li>In header files, do not use "using" statements in namespace
     713(or global) scope.
    714714
    715715<h4 class="right">Right:</h4>
     
    742742</li>
    743743
    744 <li>It is acceptable, however, to use "using" declarations at the end of
    745 header files in the WTF sub-library to include one or more names in
    746 the WTF namespace into the global scope.
     744<li>In header files in the WTF sub-library, however, it is acceptable
     745to use "using" declarations at the end of the file to import one
     746or more names in the WTF namespace into the global scope.
    747747
    748748<h4 class="right">Right:</h4>
     
    778778</li>
    779779
    780 <li>Any "using namespace" statements for a nested namespace whose parent namespace
    781 is also defined in a file must be declared within that namespace definition.
     780<li>In C++ implementation files, do not use statements of the form
     781"using std::foo" to import names in the standard template library.
     782Use "using namespace std" instead.
    782783
    783784<h4 class="right">Right:</h4>
     
    785786// HTMLBaseElement.cpp
    786787
     788using namespace std;
     789
     790namespace WebCore {
     791
     792} // namespace WebCore
     793</pre>
     794
     795<h4 class="wrong">Wrong:</h4>
     796<pre class="code">
     797// HTMLBaseElement.cpp
     798
     799using std::swap;
     800
     801namespace WebCore {
     802
     803} // namespace WebCore
     804</pre>
     805</li>
     806
     807<li>In implementation files, if a "using namespace" statement is
     808for a nested namespace whose parent namespace is defined in the file,
     809put the statement inside that namespace definition.
     810
     811<h4 class="right">Right:</h4>
     812<pre class="code">
     813// HTMLBaseElement.cpp
     814
    787815namespace WebCore {
    788816
     
    804832</li>
    805833
    806 <li>Any other "using namespace" statements must be declared before the first namespace
    807 definition in the file.
     834<li>In implementation files, put all other "using" statements
     835at the beginning of the file, before any namespace definitions and
     836after any "include" statements.
     837
    808838<h4 class="right">Right:</h4>
    809839<pre class="code">
Note: See TracChangeset for help on using the changeset viewer.