Jump to content
  • Advertisement
Sign in to follow this  
Genjix

boost::multi_array - create and initialize size on 2 lines

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i've tried this, but it errors at runtime.

	boost::multi_array<int , 2> b;
	boost::array<boost::multi_array<int , 2>::index , 2> dims = {{5 , 5}};
	b.reshape(dims);

(BTW: this seems a bit verbose, just to resize an array)

Share this post


Link to post
Share on other sites
Advertisement
this is the boost way of resizing according to the docs, yet i get runtime error

a.out: /usr/include/boost/multi_array/multi_array_ref.hpp:162: void boost::const_multi_array_ref<T, NumDims, TPtr>::reshape(const SizeList&) [with SizeList = boost::array<index, 2>, T = int, unsigned int NumDims = 2, TPtr = int*]: Assertion `num_elements_ == std::accumulate(extents.begin(),extents.end(), size_type(1),std::multiplies<size_type>())' failed.
Aborted

declaring it without a size works fine... its just when i try to shape it.

why would i want to profile this? (im not trying to micro optimize).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!