multi_array 64-bit patch

Hello, The Boost Multi_Array library produces some 64-bit related warnings when used with Visual C++.NET. It seems to me that these warnings are valid and correspond to real 64-bit problems. To get rid of these annoying warnings, I have fixed two minor inconsistencies in multi_array/iterator.hpp and multi_array/multi_array_ref.hpp, but that was not enough. I also had to change the definition of boost::detail::multi_array::index in multi_array/types.hpp from "typedef int index;" to "typedef std::ptrdiff_t index;". There might be better solutions, but it was the best I could think of, because std::ptrdiff_t is a signed type and will adapt to a 64-bit environment. Index: multi_array/iterator.hpp =================================================================== --- multi_array/iterator.hpp (Revision 1040) +++ multi_array/iterator.hpp (Arbeitskopie) @@ -98,7 +98,7 @@ array_iterator() {} - array_iterator(int idx, TPtr base, const size_type* extents, + array_iterator(index idx, TPtr base, const size_type* extents, const index* strides, const index* index_base) : idx_(idx), base_(base), extents_(extents), Index: multi_array/types.hpp =================================================================== --- multi_array/types.hpp (Revision 1040) +++ multi_array/types.hpp (Arbeitskopie) @@ -26,7 +26,7 @@ // needed typedefs typedef std::size_t size_type; -typedef int index; +typedef std::ptrdiff_t index; } // namespace multi_array } // namespace detail Index: multi_array/multi_array_ref.hpp =================================================================== --- multi_array/multi_array_ref.hpp (Revision 1040) +++ multi_array/multi_array_ref.hpp (Arbeitskopie) @@ -389,7 +389,7 @@ // Calculate the array size num_elements_ = std::accumulate(extent_list_.begin(),extent_list_.end(), - 1,std::multiplies<index>()); + size_type(1),std::multiplies<size_type>()); #if 0 assert(num_elements_ != 0); #endif

Hello Thomas, I made the changes you show below with the exception of the switch to ptrdiff_t for the index type. It's not obvious to me that that is the correct change to make, although the other changes seem straightforward. Cheers, ron On Jul 12, 2005, at 11:05 AM, Thomas Klimpel wrote:
Hello,
The Boost Multi_Array library produces some 64-bit related warnings when used with Visual C++.NET.
It seems to me that these warnings are valid and correspond to real 64-bit problems.
To get rid of these annoying warnings, I have fixed two minor inconsistencies in multi_array/iterator.hpp and multi_array/multi_array_ref.hpp, but that was not enough.
I also had to change the definition of boost::detail::multi_array::index in multi_array/types.hpp from "typedef int index;" to "typedef std::ptrdiff_t index;". There might be better solutions, but it was the best I could think of, because std::ptrdiff_t is a signed type and will adapt to a 64-bit environment.
Index: multi_array/iterator.hpp
===================================================================
--- multi_array/iterator.hpp (Revision 1040)
+++ multi_array/iterator.hpp (Arbeitskopie)
@@ -98,7 +98,7 @@
array_iterator() {}
- array_iterator(int idx, TPtr base, const size_type* extents,
+ array_iterator(index idx, TPtr base, const size_type* extents,
const index* strides,
const index* index_base) :
idx_(idx), base_(base), extents_(extents),
Index: multi_array/types.hpp
===================================================================
--- multi_array/types.hpp (Revision 1040)
+++ multi_array/types.hpp (Arbeitskopie)
@@ -26,7 +26,7 @@
// needed typedefs
typedef std::size_t size_type;
-typedef int index;
+typedef std::ptrdiff_t index;
} // namespace multi_array
} // namespace detail
Index: multi_array/multi_array_ref.hpp
===================================================================
--- multi_array/multi_array_ref.hpp (Revision 1040)
+++ multi_array/multi_array_ref.hpp (Arbeitskopie)
@@ -389,7 +389,7 @@
// Calculate the array size
num_elements_ = std::accumulate(extent_list_.begin(),extent_list_.end(),
- 1,std::multiplies<index>());
+ size_type(1),std::multiplies<size_type>());
#if 0
assert(num_elements_ != 0);
#endif
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Ronald Garcia
-
Thomas Klimpel