Skip to content

Commit cd0532b

Browse files
committed
Remove inclusion of <algorithm>
1 parent 6a9e8c7 commit cd0532b

2 files changed

Lines changed: 22 additions & 9 deletions

File tree

include/boost/array.hpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,14 @@
3737

3838
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
3939
# pragma warning(push)
40-
# pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe
4140
# 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
4343
#endif
4444

4545
#include <boost/assert.hpp>
4646
#include <boost/static_assert.hpp>
4747
#include <boost/throw_exception.hpp>
48-
#include <algorithm>
4948
#include <iterator>
5049
#include <stdexcept>
5150
#include <utility>
@@ -158,15 +157,29 @@ namespace boost {
158157

159158
// assignment with type conversion
160159
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+
163167
return *this;
164168
}
165169

166170
// fill with one value
167171
BOOST_CXX14_CONSTEXPR void fill (const T& value)
168172
{
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+
}
170183
}
171184

172185
// an obsolete synonym for fill

test/array0.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* http://www.boost.org/LICENSE_1_0.txt)
66
*/
77

8-
#include <string>
9-
#include <iostream>
108
#include <boost/array.hpp>
11-
129
#include <boost/core/lightweight_test_trait.hpp>
10+
#include <algorithm>
11+
#include <string>
12+
#include <iostream>
1313

1414
namespace {
1515

0 commit comments

Comments
 (0)