Boost.Array vs std::vector

This is a discussion on Boost.Array vs std::vector within the C++ Programming forums, part of the General Programming Boards category; This sounds wrong. Could this be true when some extra memory is needed for a dynamically allocated array and the ...

  1. #16
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    This sounds wrong.
    Could this be true when some extra memory is needed for a dynamically allocated array and the re'allocation is not contiguous ?
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,794
    Quote Originally Posted by Elysia
    Nevertheless, a true iterator also contains some mandatory typedefs describing its characteristics. And some function rely on those typedefs, which will break them when using raw pointers.
    Considering that std::iterator_traits can be used as it is specialised for pointers, the lack of those typedefs do not mean that pointers are not "true" iterators.

    Quote Originally Posted by manasij7479
    Could this be true when some extra memory is needed for a dynamically allocated array and the re'allocation is not contiguous ?
    What do you mean by "a dynamically allocated array"? Note that a std::vector's storage is contiguous.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #18
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    a normal one...like
    Code:
     int *x = new int [10];
    or realloc'ing something earlier allocated with malloc ...
    P.S:..my idea about the innards of memory allocation is poor at best ...
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  4. #19
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,663
    Quote Originally Posted by laserlight View Post
    Considering that std::iterator_traits can be used as it is specialised for pointers, the lack of those typedefs do not mean that pointers are not "true" iterators.
    I don't think that is the problem. More like that some functions will try to access T::some_type where T is the iterator type.
    *shrug* That's the problem as I know it.
    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. #20
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,794
    Quote Originally Posted by manasij7479
    a normal one... (...) or realloc'ing something earlier allocated with malloc ...
    Allocation of memory in those cases will be contiguous.

    Quote Originally Posted by Elysia
    More like that some functions will try to access T::some_type where T is the iterator type.
    Then they should be rewritten to access typename std::iterator_traits<T>::some_type.
    Last edited by laserlight; 04-19-2011 at 08:47 AM.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #21
    Registered User
    Join Date
    Sep 2010
    Posts
    90
    And to think I'm two weeks ahead of class and it's OVER in two weeks. All I got to do is the FINAL, so no more "is this HW", Never Again!

    Anyway, I was about to start another thread but was afraid to ask "How-To"... than I read you guys new post, than I did a search and I found this link ... raw pointers and std::vector< std::vector< std::string > > ... Seems related and right up my alley anyway ... and they both works perfectly. I can't wait to get into bench-marking.

    c++ - How to write the content of different files to a vector for further use with getline - Stack Overflow

    This been my interest ever since you help me Ms. Elysia in my old vector thread and was what I needed to find to justify my reason to take a few semesters of C++ in the first place! Since than it been all about vector, It and Maps for me. I learn (pick-up) more from THIS thread than I learn all year. But school was cool.

    I hope the OP can make use of this also, but it may not be nothing new to anyone but me.


    btw: the forum was noticeable smoother since the new look but got very sluggish since the temporary shut down/clean-up a day or two ago ... I just notice that this only happens when I'm log-in. It's a rocket when I'm not.
    Last edited by sharris; 04-19-2011 at 03:02 PM.

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

Similar Threads

  1. Boost tuple and Vector problem
    By LuckyPierre in forum C++ Programming
    Replies: 14
    Last Post: 09-29-2009, 01:26 AM
  2. Vector vs. array.
    By matsp in forum C++ Programming
    Replies: 37
    Last Post: 06-23-2008, 12:41 PM
  3. Array from vector.
    By Hulag in forum C++ Programming
    Replies: 5
    Last Post: 06-23-2006, 11:55 AM
  4. erasing elements from a boost::ptr_vector (boost n00b)
    By Marcos in forum C++ Programming
    Replies: 2
    Last Post: 04-04-2006, 12:54 PM
  5. Array trying to be a vector
    By Chaplin27 in forum C++ Programming
    Replies: 18
    Last Post: 03-03-2005, 08:48 PM

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