PDA

View Full Version : how to use boost multi_array in QtCreator



elflord
31st March 2009, 14:46
Hi all

Im trying to use multi_array from the boost library in QtCreator
but i always get lots of compile error

the code is the simple example from boost webpage
it seems that the problem comes from boost::extents
do i need to add some special options in my .pro file ?
thanks


#include "boost/multi_array.hpp"
#include <cassert>


// Create a 3D array that is 3 x 4 x 2
typedef boost::multi_array<double, 3> array_type;
typedef array_type::index index;
array_type A(boost::extents[3][4][2]);

// Assign values to the elements
int values = 0;
for(index i = 0; i != 3; ++i)
for(index j = 0; j != 4; ++j)
for(index k = 0; k != 2; ++k)
A[i][j][k] = values++;

// Verify values
int verify = 0;
for(index i = 0; i != 3; ++i)
for(index j = 0; j != 4; ++j)
for(index k = 0; k != 2; ++k)
assert(A[i][j][k] == verify++);

return 0;
}

talk2amulya
31st March 2009, 18:15
could you please post the errors you are getting..also whenever u post a code, select all of the code and click on "#" on the toolbar above the textbox..no need to tell you that it increases readablity and is kinda a necessity when u use a forum..i believe u'll get a warning from the administrator anyway :)

caduel
1st April 2009, 07:37
Well, you need to tell your project where to look for Boost's includes and libs.

If you're editing a .pro file, these things go into
INCLUDEPATH += <path to boost includes>
# if you're using a boost lib that is not header only (like regex)
LIBPATH += <path to boost libs>
LIBS += <any boost libs you need to link against>

Maybe with QtCreator there is a nice dialog to enter these things.

HTH