<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:58:02 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[CXX-44] Client facing headers should not say &quot;using namespace std&quot; in header scope</title>
                <link>https://jira.mongodb.org/browse/CXX-44</link>
                <project id="11980" key="CXX">C++ Driver</project>
                    <description>&lt;p&gt;mongo/bson/bsontypes.h does &apos;using namespace std&apos; in header context.&lt;/p&gt;

&lt;p&gt;Even though its contained in the mongo namespace, best practice is that names from other namespaces should be namespace qualified in headers, for the following reason:&lt;/p&gt;

&lt;p&gt;// From who knows where in my include chain...&lt;br/&gt;
class string &lt;/p&gt;
{ /* ... */ }
&lt;p&gt;;  // NOT std::string, global scope&lt;/p&gt;

&lt;p&gt;// From mongo headers...&lt;br/&gt;
#include &amp;lt;string&amp;gt;&lt;/p&gt;

&lt;p&gt;namespace mongo {&lt;br/&gt;
using namespace std;&lt;br/&gt;
class BSONObjBuilder {&lt;br/&gt;
    // ...&lt;br/&gt;
    // ERROR: &apos;string&apos; ambiguous here!!!&lt;br/&gt;
    BSONObjBuilder&amp;amp; append(const string&amp;amp; fieldName , BSONObj subObj);&lt;br/&gt;
    // ...&lt;br/&gt;
} // namespace mongo&lt;/p&gt;

&lt;p&gt;By &apos;using namespace std&apos;, and using names from the std namespace without qualification, you expose yourself to ambiguity with any global names introduced in other headers that shadow names in namespace std. When integrating the BSON headers (or other client facing headers) into complex existing applications that already integrate many libraries the potential for such conflicts materializing in practice grows considerably.&lt;/p&gt;</description>
                <environment>All</environment>
        <key id="12208">CXX-44</key>
            <summary>Client facing headers should not say &quot;using namespace std&quot; in header scope</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="2" iconUrl="https://jira.mongodb.org/images/icons/priorities/critical.svg">Critical - P2</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="andrew.morrow@mongodb.com">Andrew Morrow</assignee>
                                    <reporter username="andrew.morrow@mongodb.com">Andrew Morrow</reporter>
                        <labels>
                            <label>legacy-cxx</label>
                    </labels>
                <created>Mon, 21 Jun 2010 12:32:07 +0000</created>
                <updated>Sun, 4 May 2014 19:32:25 +0000</updated>
                            <resolved>Mon, 17 Mar 2014 15:35:45 +0000</resolved>
                                                    <fixVersion>legacy-0.8.0</fixVersion>
                                                        <votes>3</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="517438" author="xgen-internal-githook" created="Mon, 17 Mar 2014 15:23:56 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;acmorrow&apos;, u&apos;name&apos;: u&apos;Andrew Morrow&apos;, u&apos;email&apos;: u&apos;acm@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CXX-65&quot; title=&quot;Remove precompiled headers support&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CXX-65&quot;&gt;&lt;del&gt;CXX-65&lt;/del&gt;&lt;/a&gt; &lt;a href=&quot;https://jira.mongodb.org/browse/CXX-44&quot; title=&quot;Client facing headers should not say &amp;quot;using namespace std&amp;quot; in header scope&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CXX-44&quot;&gt;&lt;del&gt;CXX-44&lt;/del&gt;&lt;/a&gt; Remove pre-compiled header and using namespace std&lt;br/&gt;
Branch: legacy&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-cxx-driver/commit/85613ca750171db4b7e1c2fd64f45ba101dcf126&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-cxx-driver/commit/85613ca750171db4b7e1c2fd64f45ba101dcf126&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="515412" author="acm" created="Thu, 13 Mar 2014 18:08:00 +0000"  >&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo-cxx-driver/pull/20&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-cxx-driver/pull/20&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="496311" author="matt.kangas@10gen.com" created="Mon, 10 Feb 2014 16:50:52 +0000"  >&lt;p&gt;Note, &lt;a href=&quot;https://github.com/mongodb/mongo/pull/8&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/pull/8&lt;/a&gt; contains a Perl script to automate the conversion, plus a clientNameSpaceTest.cpp and globalNameSpacePoisoner.h to smoke out edge cases. (Pull request closed as &quot;wontfix&quot; in server codebase)&lt;/p&gt;</comment>
                            <comment id="95816" author="auto" created="Tue, 6 Mar 2012 15:53:34 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;milkie&apos;, u&apos;email&apos;: u&apos;milkie@10gen.com&apos;, u&apos;name&apos;: u&apos;Eric Milkie&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CXX-44&quot; title=&quot;Client facing headers should not say &amp;quot;using namespace std&amp;quot; in header scope&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CXX-44&quot;&gt;&lt;del&gt;SERVER-1268&lt;/del&gt;&lt;/a&gt;: don&apos;t put &quot;using namespace&quot; statements in headers&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/fd713371498dec2b2cb319c3a50c7a0c49a062ec&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/fd713371498dec2b2cb319c3a50c7a0c49a062ec&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="87573" author="popsicle" created="Sat, 11 Feb 2012 21:20:04 +0000"  >&lt;p&gt;Putting the &apos;use namespace std;&apos; into the mongodb namespace is better, but as you probably know, not a complete fix - 3rd party libraries&apos; symbols will still clash with Mongo&apos;s if you include them before Mongo headers. Of course the fix is to include them after the Mongo headers. &lt;/p&gt;</comment>
                            <comment id="44787" author="auto" created="Wed, 27 Jul 2011 13:49:16 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;erh&apos;, u&apos;name&apos;: u&apos;Eliot Horowitz&apos;, u&apos;email&apos;: u&apos;eliot@10gen.com&apos;}
&lt;p&gt;Message: in headers at least put using namespace in mongo namespace &lt;a href=&quot;https://jira.mongodb.org/browse/CXX-44&quot; title=&quot;Client facing headers should not say &amp;quot;using namespace std&amp;quot; in header scope&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CXX-44&quot;&gt;&lt;del&gt;SERVER-1268&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/8f27050318e29fe960326979a959966dc7a7b0ad&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/8f27050318e29fe960326979a959966dc7a7b0ad&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="42198" author="acm" created="Wed, 13 Jul 2011 20:46:29 +0000"  >&lt;p&gt;I am also frustrated that this has been ignored for so long, especially given how easy it is to fix and how damaging it is to client code.&lt;/p&gt;</comment>
                            <comment id="42193" author="jzwinck" created="Wed, 13 Jul 2011 20:26:41 +0000"  >&lt;p&gt;I just got burned by a really bad case of this.  In bsonobjbuilder.h (&lt;a href=&quot;http://api.mongodb.org/cplusplus/1.9.0/bsonobjbuilder_8h_source.html&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://api.mongodb.org/cplusplus/1.9.0/bsonobjbuilder_8h_source.html&lt;/a&gt;) it says &quot;using namespace std;&quot; at file scope (!!).  This is a big, huge no-no in C++, and this particular instance took two people half an hour to track down.  I&apos;m not entirely sure how we&apos;ll fix it.  Make our own dev package which patches it?  Crazy preprocessor hackery?  Stop using MongoDB?&lt;/p&gt;

&lt;p&gt;It&apos;s been over a year.  And eight months since a fix was submitted (thanks Jeff).  Please fix this now.&lt;/p&gt;</comment>
                            <comment id="20048" author="jeffd" created="Fri, 5 Nov 2010 07:22:40 +0000"  >&lt;p&gt;Hi, I posted a pull request for patches for this at: &lt;/p&gt;

&lt;p&gt;    &lt;a href=&quot;https://github.com/mongodb/mongo/pull/9&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/pull/9&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These aren&apos;t actually patches, but rather a test for 1268, and a script to automate the busy work of fixing it. I can do an actual patch if you&apos;d like but, because it touches so many headers and symbols I expect it&apos;d go stale quickly. Details are in the patches themselves, especially in the top of 1268.pl. &lt;/p&gt;

&lt;p&gt;edit - a lot of whitespace diffs in SConstruct - the only meaningful one is the line 1225:&lt;br/&gt;
+clientTests += [ clientEnv.Program( &quot;clientNamespaceTest&quot; , [ &quot;client/examples/clientNamespaceTest.cpp&quot; ] ) ]&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrh3un:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>13420</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>