Opened 10 years ago
Last modified 9 years ago
#6889 new Feature Requests
Initialise multi_array with a given value
| Reported by: | Owned by: | Ronald Garcia | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | multi_array |
| Version: | Boost 1.49.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
The multi-array only allows users to initialise all elements to a default constructed T(). That may not be desirable if you would like a different value, either for performance reasons or because the type does not support default initialisation. For example:
#include <vector>
#include <boost/multi_array.hpp>
struct no_default
{
explicit no_default(int i) {}
};
int main()
{
std::vector<no_default> v(10, no_default(3));
boost::multi_array<no_default, 3> m(boost::extents[10][10][10]); // won't compile
}
Offering constructors that accept a value to be used to initialise the elements would be the easiest fix. This would also align with std::vector usage.
Attachments (1)
Change History (3)
by , 10 years ago
| Attachment: | multi_array_accept_initial_value.diff added |
|---|
comment:2 by , 9 years ago
Replying to rodrigo.benenson@…:
Any update on this issue ?
Not to my knowledge. I don't know if I was supposed to have emailed someone with the request or anything, though - I just created this ticket, uploaded the change and that was it.

Proposed change