Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82839 - in trunk/boost/multiprecision: . cpp_int
From: john_at_[hidden]
Date: 2013-02-12 13:58:24


Author: johnmaddock
Date: 2013-02-12 13:58:23 EST (Tue, 12 Feb 2013)
New Revision: 82839
URL: http://svn.boost.org/trac/boost/changeset/82839

Log:
Get rid of MSVC C4996 warnings.
Fixes #8036.
Text files modified:
   trunk/boost/multiprecision/cpp_dec_float.hpp | 11 ++++++++
   trunk/boost/multiprecision/cpp_int.hpp | 52 ++++++++++++++++++++++++++++++++++++++++
   trunk/boost/multiprecision/cpp_int/add.hpp | 16 ++++++++++++
   3 files changed, 79 insertions(+), 0 deletions(-)

Modified: trunk/boost/multiprecision/cpp_dec_float.hpp
==============================================================================
--- trunk/boost/multiprecision/cpp_dec_float.hpp (original)
+++ trunk/boost/multiprecision/cpp_dec_float.hpp 2013-02-12 13:58:23 EST (Tue, 12 Feb 2013)
@@ -17,7 +17,11 @@
 #define BOOST_MP_CPP_DEC_FLOAT_BACKEND_HPP
 
 #include <boost/cstdint.hpp>
+#ifndef BOOST_NO_CXX11_HDR_ARRAY
+#include <array>
+#else
 #include <boost/array.hpp>
+#endif
 #include <boost/multiprecision/number.hpp>
 #include <boost/multiprecision/detail/big_lanczos.hpp>
 #include <vector>
@@ -124,10 +128,17 @@
    }
    fpclass_type;
 
+#ifndef BOOST_NO_CXX11_HDR_ARRAY
+ typedef typename mpl::if_<is_void<Allocator>,
+ std::array<boost::uint32_t, cpp_dec_float_elem_number>,
+ detail::dynamic_array<boost::uint32_t, cpp_dec_float_elem_number, Allocator>
+ >::type array_type;
+#else
    typedef typename mpl::if_<is_void<Allocator>,
       boost::array<boost::uint32_t, cpp_dec_float_elem_number>,
       detail::dynamic_array<boost::uint32_t, cpp_dec_float_elem_number, Allocator>
>::type array_type;
+#endif
 
    array_type data;
    ExponentType exp;

Modified: trunk/boost/multiprecision/cpp_int.hpp
==============================================================================
--- trunk/boost/multiprecision/cpp_int.hpp (original)
+++ trunk/boost/multiprecision/cpp_int.hpp 2013-02-12 13:58:23 EST (Tue, 12 Feb 2013)
@@ -249,7 +249,11 @@
          // Allocate a new buffer and copy everything over:
          cap = (std::min)((std::max)(cap * 4, new_size), max_limbs);
          limb_pointer pl = allocator().allocate(cap);
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(limbs(), limbs() + size(), stdext::checked_array_iterator<limb_pointer>(pl, cap));
+#else
          std::copy(limbs(), limbs() + size(), pl);
+#endif
          if(!m_internal)
             allocator().deallocate(limbs(), capacity());
          else
@@ -272,7 +276,11 @@
    BOOST_MP_FORCEINLINE cpp_int_base(const cpp_int_base& o) : allocator_type(o), m_limbs(0), m_internal(true)
    {
       resize(o.size(), o.size());
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(o.limbs(), o.limbs() + o.size(), stdext::checked_array_iterator<limb_pointer>(limbs(), size()));
+#else
       std::copy(o.limbs(), o.limbs() + o.size(), limbs());
+#endif
       m_sign = o.m_sign;
    }
 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
@@ -281,7 +289,11 @@
    {
       if(m_internal)
       {
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(o.limbs(), o.limbs() + o.size(), stdext::checked_array_iterator<limb_pointer>(limbs(), size()));
+#else
          std::copy(o.limbs(), o.limbs() + o.size(), limbs());
+#endif
       }
       else
       {
@@ -300,7 +312,11 @@
       m_internal = o.m_internal;
       if(m_internal)
       {
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(o.limbs(), o.limbs() + o.size(), stdext::checked_array_iterator<limb_pointer>(limbs(), size()));
+#else
          std::copy(o.limbs(), o.limbs() + o.size(), limbs());
+#endif
       }
       else
       {
@@ -323,7 +339,11 @@
          static_cast<allocator_type&>(*this) = static_cast<const allocator_type&>(o);
          m_limbs = 0;
          resize(o.size(), o.size());
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(o.limbs(), o.limbs() + o.size(), stdext::checked_array_iterator<limb_pointer>(limbs(), size()));
+#else
          std::copy(o.limbs(), o.limbs() + o.size(), limbs());
+#endif
          m_sign = o.m_sign;
       }
    }
@@ -461,7 +481,11 @@
    BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base() : m_wrapper(limb_type(0u)), m_limbs(1), m_sign(false) {}
    BOOST_MP_FORCEINLINE cpp_int_base(const cpp_int_base& o) BOOST_NOEXCEPT : m_limbs(o.m_limbs), m_sign(o.m_sign)
    {
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(o.limbs(), o.limbs() + o.size(), stdext::checked_array_iterator<limb_pointer>(limbs(), size()));
+#else
       std::copy(o.limbs(), o.limbs() + o.size(), limbs());
+#endif
    }
    //~cpp_int_base() BOOST_NOEXCEPT {}
    void assign(const cpp_int_base& o) BOOST_NOEXCEPT
@@ -469,7 +493,11 @@
       if(this != &o)
       {
          resize(o.size(), o.size());
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(o.limbs(), o.limbs() + o.size(), stdext::checked_array_iterator<limb_pointer>(limbs(), size()));
+#else
          std::copy(o.limbs(), o.limbs() + o.size(), limbs());
+#endif
          m_sign = o.m_sign;
       }
    }
@@ -585,7 +613,11 @@
    BOOST_MP_FORCEINLINE cpp_int_base(const cpp_int_base& o) BOOST_NOEXCEPT
       : m_limbs(o.m_limbs)
    {
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(o.limbs(), o.limbs() + o.size(), stdext::checked_array_iterator<limb_pointer>(limbs(), size()));
+#else
       std::copy(o.limbs(), o.limbs() + o.size(), limbs());
+#endif
    }
    //~cpp_int_base() BOOST_NOEXCEPT {}
    BOOST_MP_FORCEINLINE void assign(const cpp_int_base& o) BOOST_NOEXCEPT
@@ -593,7 +625,11 @@
       if(this != &o)
       {
          resize(o.size(), o.size());
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(o.limbs(), o.limbs() + o.size(), stdext::checked_array_iterator<limb_pointer>(limbs(), size()));
+#else
          std::copy(o.limbs(), o.limbs() + o.size(), limbs());
+#endif
       }
    }
 private:
@@ -1018,7 +1054,11 @@
    {
       // regular non-trivial to non-trivial assign:
       this->resize(other.size(), other.size());
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(other.limbs(), other.limbs() + (std::min)(other.size(), this->size()), stdext::checked_array_iterator<limb_pointer>(this->limbs(), this->size()));
+#else
       std::copy(other.limbs(), other.limbs() + (std::min)(other.size(), this->size()), this->limbs());
+#endif
       this->sign(other.sign());
       this->normalize();
    }
@@ -1093,7 +1133,11 @@
       : base_type()
    {
       this->resize(other.size(), other_size());
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(other.limbs(), other.limbs() + (std::min)(other.size(), this->size()), stdext::checked_array_iterator<limb_pointer>(this->limbs(), this->size()));
+#else
       std::copy(other.limbs(), other.limbs() + (std::min)(other.size(), this->size()), this->limbs());
+#endif
       this->sign(other.sign());
    }
 
@@ -1125,7 +1169,11 @@
       : base_type()
    {
       this->resize(other.size(), other.size());
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(other.limbs(), other.limbs() + (std::min)(other.size(), this->size()), stdext::checked_array_iterator<limb_pointer>(this->limbs(), this->size()));
+#else
       std::copy(other.limbs(), other.limbs() + (std::min)(other.size(), this->size()), this->limbs());
+#endif
       this->sign(other.sign());
    }
 
@@ -1152,7 +1200,11 @@
       operator=(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Allocator2>& other)
    {
       this->resize(other.size(), other.size());
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(other.limbs(), other.limbs() + (std::min)(other.size(), this->size()), stdext::checked_array_iterator<limb_pointer>(this->limbs(), this->size()));
+#else
       std::copy(other.limbs(), other.limbs() + (std::min)(other.size(), this->size()), this->limbs());
+#endif
       this->sign(other.sign());
       return *this;
    }

Modified: trunk/boost/multiprecision/cpp_int/add.hpp
==============================================================================
--- trunk/boost/multiprecision/cpp_int/add.hpp (original)
+++ trunk/boost/multiprecision/cpp_int/add.hpp 2013-02-12 13:58:23 EST (Tue, 12 Feb 2013)
@@ -55,7 +55,11 @@
       if(!carry)
       {
          if(pa != pr)
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(pa, pa + (pr_end - pr), stdext::checked_array_iterator<limb_type*>(pr, result.size()));
+#else
             std::copy(pa, pa + (pr_end - pr), pr);
+#endif
          break;
       }
       carry += static_cast<double_limb_type>(*pa);
@@ -180,7 +184,11 @@
    }
    // Any remaining digits are the same as those in pa:
    if((x != i) && (pa != pr))
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(pa + i, pa + x, stdext::checked_array_iterator<limb_type*>(pr + i, result.size() - i));
+#else
       std::copy(pa + i, pa + x, pr + i);
+#endif
    BOOST_ASSERT(0 == borrow);
 
    //
@@ -208,7 +216,11 @@
       *pr = *pa - b;
       if(&result != &a)
       {
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(pa + 1, pa + a.size(), stdext::checked_array_iterator<limb_type*>(pr + 1, result.size() - 1));
+#else
          std::copy(pa + 1, pa + a.size(), pr + 1);
+#endif
          result.sign(a.sign());
       }
    }
@@ -230,7 +242,11 @@
       if(&result != &a)
       {
          ++i;
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
+ std::copy(pa + i, pa + a.size(), stdext::checked_array_iterator<limb_type*>(pr + i, result.size() - i));
+#else
          std::copy(pa + i, pa + a.size(), pr + i);
+#endif
       }
       result.normalize();
       result.sign(a.sign());


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk