queue of int arrays

This is a discussion on queue of int arrays within the C++ Programming forums, part of the General Programming Boards category; I know I can do this: Code: queue<int*> But then I have to allocate and deallocate each member. I also ...

  1. #1
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300

    queue of int arrays

    I know I can do this:

    Code:
    queue<int*>
    But then I have to allocate and deallocate each member. I also know I can:

    Code:
    queue< queue<int> >
    But I don't like that because I don't need a queue of queues. All I need is a queue of arrays:

    Code:
    queue<int[4]>
    But int[4] is not a real datatype. Or have I missed something?
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,339
    What about
    queue < vector < int > >
    then?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Salem View Post
    What about
    queue < vector < int > >
    then?
    Sure, but the "low level" guy in me just says that shouldn't be necessary. I was hoping there was a way to use fixed size arrays in a template, but if there isn't, I won't loose any sleep.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    Registered User
    Join Date
    Dec 2008
    Location
    Black River
    Posts
    128
    maybe something like this?

    Code:
    struct myt {
        int data[4];
    };
    
    queue<myt> myq;
    Stick close to your desks and never program a thing,
    And you all may sit in the standards commitee!

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Ronix View Post
    maybe something like this?

    Code:
    struct myt {
        int data[4];
    };
    
    queue<myt> myq;
    Shucks, I guess that is pretty obvious, thanks.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,172
    There is still std::array.
    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.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. (queue*)this)->queue::qput does not have class type
    By brack in forum C++ Programming
    Replies: 13
    Last Post: 11-11-2010, 02:41 PM
  2. queue
    By hokuokekai in forum C++ Programming
    Replies: 1
    Last Post: 10-15-2010, 09:19 AM
  3. Queue
    By LePlusMieux in forum C++ Programming
    Replies: 3
    Last Post: 02-24-2003, 03:56 PM
  4. Queue
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 12-14-2001, 11:21 AM
  5. Queue and Priority Queue
    By Pamela in forum C++ Programming
    Replies: 1
    Last Post: 12-07-2001, 10:09 PM

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