Boost multi_array question

This is a discussion on Boost multi_array question within the C++ Programming forums, part of the General Programming Boards category; Hi all, I've just decided to pick up boost for use in one of my programs, and I've been having ...

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    9

    Boost multi_array question

    Hi all, I've just decided to pick up boost for use in one of my programs, and I've been having trouble with initialising a multi_array. The problem that I've been having is trying to make a multi dimensional array of a class, something like this:

    class foo
    {
    public:
    foo(int _x){x = _x}
    ~foo(){}
    private:
    int x;
    };

    boost::multi_array< foo , 2 > array( boost::extents[100][100]);

    I have no idea where to call the classes constructor, or how to make sure that there is enough memory allocated to hold it, any help at all appreciated.
    Last edited by Raptoricus; 07-16-2009 at 05:11 PM. Reason: <edit> numerous times, spelling

  2. #2
    Registered User
    Join Date
    Jul 2009
    Posts
    9
    Shameless bump here, I really need to find this out.
    If anythings unclear, please ask me to clarify .

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    So far as I can tell, it's the default constructor or nothing at all.

  4. #4
    Registered User
    Join Date
    Jul 2009
    Posts
    9
    Ugh, that's exactly what I didn't want to hear. If anyone knows of a way to use a non default constructor, please help

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Hm, interesting omission. Perhaps you should bring this issue up on the Boost mailing lists.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  6. #6
    Registered User
    Join Date
    Jul 2009
    Posts
    9
    I might just do that, I don't know about you people, but I make arrays/vectors of classes all the time, and after doing some reading into boost/multi_array, it seemed like the answer to a few problems that I'd been having. But seems like this was something that they either didn't think of, or there's something that I'm missing. Thanks for the help anyway guys.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 12-12-2007, 05:45 AM
  2. building boost iostreams
    By l2u in forum C++ Programming
    Replies: 3
    Last Post: 04-14-2007, 02:29 PM
  3. Integrating Boost with STLPort
    By Mario F. in forum Tech Board
    Replies: 1
    Last Post: 11-11-2006, 05:49 AM
  4. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  5. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM

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