|
37 | 37 |
|
38 | 38 | #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) |
39 | 39 | # pragma warning(push) |
40 | | -# pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe |
41 | 40 | # pragma warning(disable:4510) // boost::array<T,N>' : default constructor could not be generated |
42 | | -# pragma warning(disable:4610) // warning C4610: class 'boost::array<T,N>' can never be instantiated - user defined constructor required |
| 41 | +# pragma warning(disable:4512) // boost::array<T,N>' : assignment operator could not be generated |
| 42 | +# pragma warning(disable:4610) // class 'boost::array<T,N>' can never be instantiated - user defined constructor required |
43 | 43 | #endif |
44 | 44 |
|
45 | 45 | #include <boost/assert.hpp> |
46 | 46 | #include <boost/static_assert.hpp> |
47 | 47 | #include <boost/throw_exception.hpp> |
48 | | -#include <algorithm> |
49 | 48 | #include <iterator> |
50 | 49 | #include <stdexcept> |
51 | 50 | #include <utility> |
@@ -158,15 +157,29 @@ namespace boost { |
158 | 157 |
|
159 | 158 | // assignment with type conversion |
160 | 159 | template <typename T2> |
161 | | - array<T,N>& operator= (const array<T2,N>& rhs) { |
162 | | - std::copy(rhs.begin(),rhs.end(), begin()); |
| 160 | + array<T,N>& operator= (const array<T2,N>& rhs) |
| 161 | + { |
| 162 | + for( std::size_t i = 0; i < N; ++i ) |
| 163 | + { |
| 164 | + elems[ i ] = rhs.elems[ i ]; |
| 165 | + } |
| 166 | + |
163 | 167 | return *this; |
164 | 168 | } |
165 | 169 |
|
166 | 170 | // fill with one value |
167 | 171 | BOOST_CXX14_CONSTEXPR void fill (const T& value) |
168 | 172 | { |
169 | | - std::fill_n(begin(),size(),value); |
| 173 | + // using elems[ 0 ] as a temporary copy |
| 174 | + // avoids the aliasing opportunity betw. |
| 175 | + // `value` and `elems` |
| 176 | + |
| 177 | + elems[ 0 ] = value; |
| 178 | + |
| 179 | + for( std::size_t i = 1; i < N; ++i ) |
| 180 | + { |
| 181 | + elems[ i ] = elems[ 0 ]; |
| 182 | + } |
170 | 183 | } |
171 | 184 |
|
172 | 185 | // an obsolete synonym for fill |
|
0 commit comments