[Boost-bugs] [Boost C++ Libraries] #6889: Initialise multi_array with a given value

Subject: [Boost-bugs] [Boost C++ Libraries] #6889: Initialise multi_array with a given value
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-05-11 03:21:56


#6889: Initialise multi_array with a given value
----------------------------------------------------+-----------------------
 Reporter: Andrew Morris <andy@…> | Owner: garcia
     Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: multi_array
  Version: Boost 1.49.0 | Severity: Problem
 Keywords: |
----------------------------------------------------+-----------------------
 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.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6889>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC