From cd0532b8fa858f15ae40191cc1428acbad1335fc Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 04:54:58 +0200 Subject: [PATCH] Remove inclusion of --- include/boost/array.hpp | 25 +++++++++++++++++++------ test/array0.cpp | 6 +++--- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index b54cf06..9d251f7 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -37,15 +37,14 @@ #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) # pragma warning(push) -# pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe # pragma warning(disable:4510) // boost::array' : default constructor could not be generated -# pragma warning(disable:4610) // warning C4610: class 'boost::array' can never be instantiated - user defined constructor required +# pragma warning(disable:4512) // boost::array' : assignment operator could not be generated +# pragma warning(disable:4610) // class 'boost::array' can never be instantiated - user defined constructor required #endif #include #include #include -#include #include #include #include @@ -158,15 +157,29 @@ namespace boost { // assignment with type conversion template - array& operator= (const array& rhs) { - std::copy(rhs.begin(),rhs.end(), begin()); + array& operator= (const array& rhs) + { + for( std::size_t i = 0; i < N; ++i ) + { + elems[ i ] = rhs.elems[ i ]; + } + return *this; } // fill with one value BOOST_CXX14_CONSTEXPR void fill (const T& value) { - std::fill_n(begin(),size(),value); + // using elems[ 0 ] as a temporary copy + // avoids the aliasing opportunity betw. + // `value` and `elems` + + elems[ 0 ] = value; + + for( std::size_t i = 1; i < N; ++i ) + { + elems[ i ] = elems[ 0 ]; + } } // an obsolete synonym for fill diff --git a/test/array0.cpp b/test/array0.cpp index af1d47b..e3a6262 100644 --- a/test/array0.cpp +++ b/test/array0.cpp @@ -5,11 +5,11 @@ * http://www.boost.org/LICENSE_1_0.txt) */ +#include +#include +#include #include #include -#include - -#include namespace {