{"action":"created","issue":{"url":"https://api.github.com/repos/isocpp/CppCoreGuidelines/issues/391","repository_url":"https://api.github.com/repos/isocpp/CppCoreGuidelines","labels_url":"https://api.github.com/repos/isocpp/CppCoreGuidelines/issues/391/labels{/name}","comments_url":"https://api.github.com/repos/isocpp/CppCoreGuidelines/issues/391/comments","events_url":"https://api.github.com/repos/isocpp/CppCoreGuidelines/issues/391/events","html_url":"https://github.com/isocpp/CppCoreGuidelines/issues/391","id":117012264,"number":391,"title":"consider using std:: prefix","user":{"login":"cpu-chromium","id":12821707,"avatar_url":"https://avatars.githubusercontent.com/u/12821707?v=3","gravatar_id":"","url":"https://api.github.com/users/cpu-chromium","html_url":"https://github.com/cpu-chromium","followers_url":"https://api.github.com/users/cpu-chromium/followers","following_url":"https://api.github.com/users/cpu-chromium/following{/other_user}","gists_url":"https://api.github.com/users/cpu-chromium/gists{/gist_id}","starred_url":"https://api.github.com/users/cpu-chromium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpu-chromium/subscriptions","organizations_url":"https://api.github.com/users/cpu-chromium/orgs","repos_url":"https://api.github.com/users/cpu-chromium/repos","events_url":"https://api.github.com/users/cpu-chromium/events{/privacy}","received_events_url":"https://api.github.com/users/cpu-chromium/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/isocpp/CppCoreGuidelines/labels/open","name":"open","color":"5319e7"}],"state":"open","locked":false,"assignee":{"login":"gdr-at-ms","id":11031650,"avatar_url":"https://avatars.githubusercontent.com/u/11031650?v=3","gravatar_id":"","url":"https://api.github.com/users/gdr-at-ms","html_url":"https://github.com/gdr-at-ms","followers_url":"https://api.github.com/users/gdr-at-ms/followers","following_url":"https://api.github.com/users/gdr-at-ms/following{/other_user}","gists_url":"https://api.github.com/users/gdr-at-ms/gists{/gist_id}","starred_url":"https://api.github.com/users/gdr-at-ms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gdr-at-ms/subscriptions","organizations_url":"https://api.github.com/users/gdr-at-ms/orgs","repos_url":"https://api.github.com/users/gdr-at-ms/repos","events_url":"https://api.github.com/users/gdr-at-ms/events{/privacy}","received_events_url":"https://api.github.com/users/gdr-at-ms/received_events","type":"User","site_admin":false},"milestone":null,"comments":17,"created_at":"2015-11-15T19:24:30Z","updated_at":"2016-03-15T16:59:56Z","closed_at":null,"body":"For example in P.1\r\n\r\n auto p = find(v, val);\r\n\r\nIf we ever get an a library with ranges then presumably this becomes even more important, as there could be a std2:find."},"comment":{"url":"https://api.github.com/repos/isocpp/CppCoreGuidelines/issues/comments/196922669","html_url":"https://github.com/isocpp/CppCoreGuidelines/issues/391#issuecomment-196922669","issue_url":"https://api.github.com/repos/isocpp/CppCoreGuidelines/issues/391","id":196922669,"user":{"login":"MichaelCook","id":3008060,"avatar_url":"https://avatars.githubusercontent.com/u/3008060?v=3","gravatar_id":"","url":"https://api.github.com/users/MichaelCook","html_url":"https://github.com/MichaelCook","followers_url":"https://api.github.com/users/MichaelCook/followers","following_url":"https://api.github.com/users/MichaelCook/following{/other_user}","gists_url":"https://api.github.com/users/MichaelCook/gists{/gist_id}","starred_url":"https://api.github.com/users/MichaelCook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MichaelCook/subscriptions","organizations_url":"https://api.github.com/users/MichaelCook/orgs","repos_url":"https://api.github.com/users/MichaelCook/repos","events_url":"https://api.github.com/users/MichaelCook/events{/privacy}","received_events_url":"https://api.github.com/users/MichaelCook/received_events","type":"User","site_admin":false},"created_at":"2016-03-15T16:59:56Z","updated_at":"2016-03-15T16:59:56Z","body":"I think the only time one should use \"using namespace foo\" is when the\nmaintainer of foo has access to your source code and would be able to catch\nand perhaps fix problems when the maintainer adds a new symbol to the foo\nnamespace. For example, when the definition and uses of foo are all within\nthe same project.\n\nOn Tue, Mar 15, 2016 at 12:31 PM, Galik <notifications@github.com> wrote:\n\n> I am of the opinion that *sometimes* using namespace ... is useful, even\n> in header files (as long as its not in the global *namespace*) for\n> limited numbers of symbols that rightfully can be considered as being a\n> part of another *namespace*. But with truly massive *namespaces* like\n> std:: don't fall into this category. Furthermore the sheer extent and\n> character of the symbols they contain always leads to potentially hard to\n> find bugs, even if used in a .cpp file.\n>\n> So I recommend *always* prefixing with std:: or other large general\n> purpose *namespaces* (or using declarations or namespace aliasing) except\n> in very limited, local scopes.\n>\n> What I might consider a ligitimate use would be for example:\n>\n> namespace mylib { namespace types {\n> using size_type = std::size_t;using integral = std::int32_t;using real = double;using clock = std::chrono::steady_clock;using period = clock::period;using duration = clock::duration;\n>\n> }} // mylib::types\n> // ...\n> namespace my_project {\n> using namespace mylib::types; // don't bother redeclaring all those types, just import them\n> // ...\n>\n> } // my_project\n>\n> Another way I use this is to have *namespace* groups within a larger\n> project namespace so that including the larger namespace still leaves you\n> with group namespace prefixes to keep from polluting your larger codebase.\n>\n> namespace my_algorithm_library { namespace stl {\n> template<typename Iter>\n> Iter algorithm1(Iter a, Iter b)\n> {\n>     // ...\n> }// etc..\n> }} // my_algorithm_library::stl\n> // ...\n> namespace my_project {\n> using namespace my_algorithm_library;// still have to further qualify names here ...\n> void func(std::vector<int>& v)\n> {\n>     auto i = stl::algorithm1(v.begin(), v.end());\n>     // ...\n> }\n>\n> } // my_project\n>\n> By having the second level of namespace you still need to qualify symbols\n> from the larger namespace you included and any ambiguities there could be\n> fixed using *namespace aliases*.\n>\n> —\n> You are receiving this because you are subscribed to this thread.\n> Reply to this email directly or view it on GitHub:\n>\n> https://github.com/isocpp/CppCoreGuidelines/issues/391#issuecomment-196909258\n>\n"}}