std namespace terms

This is a discussion on std namespace terms within the C++ Programming forums, part of the General Programming Boards category; Does anyone have a good link where you can find a list of terms specific to the std namespace? I've ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    242

    std namespace terms

    Does anyone have a good link where you can find a list of terms specific to the std namespace?

    I've just reached the point where simply throwing in "using namespace std;" at the top of every page is becoming inadequate. So, I'd like to know just what terms need to be prefaced with std:: when you leave out that using directive.

    Also, do more experienced programmers tend to favor (as Prata suggests) the greater precision of using declarations of individual terms? I can see how using directives could lead to confusion in large programs involving multiple namespaces anyway.

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Every class in the standard C++ library is contained in the std namespace.
    C++ Reference [C++ Reference]
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,344
    >> do more experienced programmers tend to favor (as Prata suggests) the greater precision of using declarations of individual terms?

    It really varies. Sutter and Alexandrescu indicate that using directives are fine (as long as they are confined to source files after all the #includes). Koenig and Moo use the std:: prefix on all standard names in their book. Different experienced programmers on this site have different preferences as well (there are many threads on this subject available to search through).

    Personally, I prefer to use the std:: prefix everywhere to maintain consistency between header and source files and to make the code clearer (it makes it obvious which library the name came from).

    I'd imagine that in large programs that make extensive use of the standard library that using declarations would get tedious (since you have to add one for every name you use). I'm not aware of many people who use that technique unless there are only a couple of names to declare.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,918
    Quote Originally Posted by Daved View Post
    ...Koenig and Moo use the std:: prefix on all standard names in their book...
    Do they? If I remember correctly, they are the authors of Accelerated C++, where they tended to add using directives for everything from the standard library.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,344
    You might be right. Someone recently had a thread where they showed code from the Accelerated C++ book and wondered why they used the prefix, but that might have been an isolated incident. It has been so long since I've looked that I don't remember for sure.

    Note that the few pages displayed on amazon all use the std:: prefix.
    Last edited by Daved; 08-01-2009 at 04:49 PM.

  6. #6
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    Quote Originally Posted by Elysia View Post
    Do they? If I remember correctly, they are the authors of Accelerated C++, where they tended to add using directives for everything from the standard library.
    Yep, I believe in the start they use the std:: prefix and switch to the using directives as the book progresses.
    Spidey out!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thoughts about using namespace std?
    By dwks in forum C++ Programming
    Replies: 40
    Last Post: 09-25-2008, 06:14 PM
  2. using namespace std error
    By Kayoss in forum C++ Programming
    Replies: 0
    Last Post: 04-26-2006, 02:56 PM
  3. using namespace std;
    By spank in forum C++ Programming
    Replies: 3
    Last Post: 01-20-2006, 06:28 AM
  4. using namespace std, What does it do?
    By Ben K. in forum C++ Programming
    Replies: 1
    Last Post: 10-14-2001, 11:42 PM
  5. What is "using namespace std; "
    By Engel32 in forum C++ Programming
    Replies: 3
    Last Post: 09-28-2001, 08:23 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21