Thoughts on return type from template container classes.

This is a discussion on Thoughts on return type from template container classes. within the C++ Programming forums, part of the General Programming Boards category; I guess it just doesn't matter than but I've always used the list implementation....

  1. #16
    Chi! whiteflags's Avatar
    Join Date
    Apr 2006
    United States
    I guess it just doesn't matter than but I've always used the list implementation.
    Last edited by whiteflags; 10-16-2010 at 07:29 PM. Reason: GAAH I don't know anymore

  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Quote Originally Posted by Elysia
    You can easily insert and pop at the end of an array in stacks, making it a generally good choice with on consequences.
    In fact, the std::stack adapter uses back(), push_back() and pop_back(). I believe the reason why std::deque is the default has to do with the fact that std::vector does not reduce its capacity automatically, so you have to use the swap with empty container trick.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #18
    Join Date
    Oct 2007
    Ahhh, that explains why it's using std::deque by default.

    Quote Originally Posted by Subsonics View Post
    Ok, thanks. I just got worried about returning a local variable, but it seems to work as intended.
    It's never wrong to return a local variable unless you are returning a reference to a local variable.
    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.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  3. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  4. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 11:54 AM

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