From 0309a36305f68e0d793280f4461844293d5da5e9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Mon, 14 Apr 2014 11:40:26 +0200
Subject: [PATCH 2/4] multi_array: fix GCC -Wshadow warnings
Signed-off-by: Michael Stahl <mstahl@redhat.com>
---
include/boost/multi_array.hpp | 24 ++++-----
include/boost/multi_array/concept_checks.hpp | 38 ++++++-------
include/boost/multi_array/extent_range.hpp | 8 +--
include/boost/multi_array/index_range.hpp | 12 ++---
include/boost/multi_array/multi_array_ref.hpp | 78 +++++++++++++--------------
include/boost/multi_array/storage_order.hpp | 8 +--
include/boost/multi_array/subarray.hpp | 8 +--
include/boost/multi_array/view.hpp | 8 +--
8 files changed, 92 insertions(+), 92 deletions(-)
diff --git a/include/boost/multi_array.hpp b/include/boost/multi_array.hpp
index f459ce9..8193699 100644
a
|
b
|
public:
|
139 | 139 | |
140 | 140 | explicit multi_array() : |
141 | 141 | super_type((T*)initial_base_,c_storage_order(), |
142 | | /*index_bases=*/0, /*extents=*/0) { |
| 142 | /*index_bases=*/0, /*extents_=*/0) { |
143 | 143 | allocate_space(); |
144 | 144 | } |
145 | 145 | |
146 | 146 | template <class ExtentList> |
147 | 147 | explicit multi_array( |
148 | | ExtentList const& extents |
| 148 | ExtentList const& extents_ |
149 | 149 | #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING |
150 | 150 | , typename mpl::if_< |
151 | 151 | detail::multi_array::is_multi_array_impl<ExtentList>, |
152 | 152 | int&,int>::type* = 0 |
153 | 153 | #endif |
154 | 154 | ) : |
155 | | super_type((T*)initial_base_,extents) { |
| 155 | super_type((T*)initial_base_,extents_) { |
156 | 156 | boost::function_requires< |
157 | 157 | detail::multi_array::CollectionConcept<ExtentList> >(); |
158 | 158 | allocate_space(); |
… |
… |
public:
|
160 | 160 | |
161 | 161 | |
162 | 162 | template <class ExtentList> |
163 | | explicit multi_array(ExtentList const& extents, |
| 163 | explicit multi_array(ExtentList const& extents_, |
164 | 164 | const general_storage_order<NumDims>& so) : |
165 | | super_type((T*)initial_base_,extents,so) { |
| 165 | super_type((T*)initial_base_,extents_,so) { |
166 | 166 | boost::function_requires< |
167 | 167 | detail::multi_array::CollectionConcept<ExtentList> >(); |
168 | 168 | allocate_space(); |
169 | 169 | } |
170 | 170 | |
171 | 171 | template <class ExtentList> |
172 | | explicit multi_array(ExtentList const& extents, |
| 172 | explicit multi_array(ExtentList const& extents_, |
173 | 173 | const general_storage_order<NumDims>& so, |
174 | 174 | Allocator const& alloc) : |
175 | | super_type((T*)initial_base_,extents,so), allocator_(alloc) { |
| 175 | super_type((T*)initial_base_,extents_,so), allocator_(alloc) { |
176 | 176 | boost::function_requires< |
177 | 177 | detail::multi_array::CollectionConcept<ExtentList> >(); |
178 | 178 | allocate_space(); |
… |
… |
public:
|
381 | 381 | |
382 | 382 | |
383 | 383 | template <typename ExtentList> |
384 | | multi_array& resize(const ExtentList& extents) { |
| 384 | multi_array& resize(const ExtentList& extents_) { |
385 | 385 | boost::function_requires< |
386 | 386 | detail::multi_array::CollectionConcept<ExtentList> >(); |
387 | 387 | |
… |
… |
public:
|
390 | 390 | |
391 | 391 | for (int i=0; i != NumDims; ++i) { |
392 | 392 | typedef typename gen_type::range range_type; |
393 | | ranges.ranges_[i] = range_type(0,extents[i]); |
| 393 | ranges.ranges_[i] = range_type(0,extents_[i]); |
394 | 394 | } |
395 | 395 | |
396 | 396 | return this->resize(ranges); |
… |
… |
public:
|
423 | 423 | // Build index_gen objects to create views with the same shape |
424 | 424 | |
425 | 425 | // these need to be separate to handle non-zero index bases |
426 | | typedef detail::multi_array::index_gen<NumDims,NumDims> index_gen; |
427 | | index_gen old_idxes; |
428 | | index_gen new_idxes; |
| 426 | typedef detail::multi_array::index_gen<NumDims,NumDims> lcl_index_gen; |
| 427 | lcl_index_gen old_idxes; |
| 428 | lcl_index_gen new_idxes; |
429 | 429 | |
430 | 430 | std::transform(new_array.index_base_list_.begin(), |
431 | 431 | new_array.index_base_list_.end(), |
diff --git a/include/boost/multi_array/concept_checks.hpp b/include/boost/multi_array/concept_checks.hpp
index ea0c1aa..7e5ba5d 100644
a
|
b
|
namespace detail {
|
39 | 39 | |
40 | 40 | template <typename Array, typename IdxGen, typename Call_Type> |
41 | 41 | static void call(Array& a, const IdxGen& idgen, Call_Type c) { |
42 | | typedef typename Array::index_range index_range; |
43 | | typedef typename Array::index index; |
| 42 | typedef typename Array::index_range index_range_; |
| 43 | typedef typename Array::index index_; |
44 | 44 | idgen_helper<N-1>::call(a,idgen[c],c); |
45 | 45 | } |
46 | 46 | }; |
… |
… |
namespace detail {
|
50 | 50 | |
51 | 51 | template <typename Array, typename IdxGen, typename Call_Type> |
52 | 52 | static void call(Array& a, const IdxGen& idgen, Call_Type) { |
53 | | typedef typename Array::index_range index_range; |
54 | | typedef typename Array::index index; |
| 53 | typedef typename Array::index_range index_range_; |
| 54 | typedef typename Array::index index_; |
55 | 55 | a[ idgen ]; |
56 | 56 | } |
57 | 57 | }; |
… |
… |
namespace detail {
|
166 | 166 | const_constraints(a); |
167 | 167 | } |
168 | 168 | |
169 | | void const_constraints(const Array& a) { |
| 169 | void const_constraints(const Array& a_) { |
170 | 170 | |
171 | 171 | // value_type vt = a[ id ]; |
172 | 172 | |
173 | 173 | // Test slicing, keeping only the first dimension, losing the rest |
174 | | detail::idgen_helper<NumDims-1>::call(a,idgen[range],id); |
| 174 | detail::idgen_helper<NumDims-1>::call(a_,idgen[range],id); |
175 | 175 | |
176 | 176 | // Test slicing, keeping all dimensions. |
177 | | detail::idgen_helper<NumDims-1>::call(a,idgen[range],range); |
178 | | |
179 | | st = a.size(); |
180 | | st = a.num_dimensions(); |
181 | | st = a.num_elements(); |
182 | | stp = a.shape(); |
183 | | idp = a.strides(); |
184 | | idp = a.index_bases(); |
185 | | cit = a.begin(); |
186 | | cit = a.end(); |
187 | | crit = a.rbegin(); |
188 | | crit = a.rend(); |
189 | | eltp = a.origin(); |
| 177 | detail::idgen_helper<NumDims-1>::call(a_,idgen[range],range); |
| 178 | |
| 179 | st = a_.size(); |
| 180 | st = a_.num_dimensions(); |
| 181 | st = a_.num_elements(); |
| 182 | stp = a_.shape(); |
| 183 | idp = a_.strides(); |
| 184 | idp = a_.index_bases(); |
| 185 | cit = a_.begin(); |
| 186 | cit = a_.end(); |
| 187 | crit = a_.rbegin(); |
| 188 | crit = a_.rend(); |
| 189 | eltp = a_.origin(); |
190 | 190 | } |
191 | 191 | |
192 | 192 | typedef typename Array::value_type value_type; |
diff --git a/include/boost/multi_array/extent_range.hpp b/include/boost/multi_array/extent_range.hpp
index d7a2eaf..b6d7706 100644
a
|
b
|
public:
|
26 | 26 | typedef Extent index; |
27 | 27 | typedef SizeType size_type; |
28 | 28 | |
29 | | extent_range(index start, index finish) : |
30 | | super_type(start,finish) { } |
| 29 | extent_range(index start_, index finish_) : |
| 30 | super_type(start_,finish_) { } |
31 | 31 | |
32 | | extent_range(index finish) : |
33 | | super_type(0,finish) { } |
| 32 | extent_range(index finish_) : |
| 33 | super_type(0,finish_) { } |
34 | 34 | |
35 | 35 | extent_range() : super_type(0,0) { } |
36 | 36 | |
diff --git a/include/boost/multi_array/index_range.hpp b/include/boost/multi_array/index_range.hpp
index 3d6035e..42cd351 100644
a
|
b
|
namespace multi_array {
|
60 | 60 | degenerate_ = true; |
61 | 61 | } |
62 | 62 | |
63 | | explicit index_range(index start, index finish, index stride=1) |
64 | | : start_(start), finish_(finish), stride_(stride), |
| 63 | explicit index_range(index i_start, index i_finish, index i_stride=1) |
| 64 | : start_(i_start), finish_(i_finish), stride_(i_stride), |
65 | 65 | degenerate_(false) |
66 | 66 | { } |
67 | 67 | |
… |
… |
namespace multi_array {
|
107 | 107 | |
108 | 108 | index stride() const { return stride_; } |
109 | 109 | |
110 | | void set_index_range(index start, index finish, index stride=1) |
| 110 | void set_index_range(index i_start, index i_finish, index i_stride=1) |
111 | 111 | { |
112 | | start_ = start; |
113 | | finish_ = finish; |
114 | | stride_ = stride; |
| 112 | start_ = i_start; |
| 113 | finish_ = i_finish; |
| 114 | stride_ = i_stride; |
115 | 115 | } |
116 | 116 | |
117 | 117 | static index_range all() |
diff --git a/include/boost/multi_array/multi_array_ref.hpp b/include/boost/multi_array/multi_array_ref.hpp
index 92e8fb4..511c816 100644
a
|
b
|
public:
|
87 | 87 | num_elements_(other.num_elements_) { } |
88 | 88 | |
89 | 89 | template <typename ExtentList> |
90 | | explicit const_multi_array_ref(TPtr base, const ExtentList& extents) : |
| 90 | explicit const_multi_array_ref(TPtr base, const ExtentList& extents_) : |
91 | 91 | base_(base), storage_(c_storage_order()) { |
92 | 92 | boost::function_requires< |
93 | 93 | CollectionConcept<ExtentList> >(); |
94 | 94 | |
95 | 95 | index_base_list_.assign(0); |
96 | | init_multi_array_ref(extents.begin()); |
| 96 | init_multi_array_ref(extents_.begin()); |
97 | 97 | } |
98 | 98 | |
99 | 99 | template <typename ExtentList> |
100 | | explicit const_multi_array_ref(TPtr base, const ExtentList& extents, |
| 100 | explicit const_multi_array_ref(TPtr base, const ExtentList& extents_, |
101 | 101 | const general_storage_order<NumDims>& so) : |
102 | 102 | base_(base), storage_(so) { |
103 | 103 | boost::function_requires< |
104 | 104 | CollectionConcept<ExtentList> >(); |
105 | 105 | |
106 | 106 | index_base_list_.assign(0); |
107 | | init_multi_array_ref(extents.begin()); |
| 107 | init_multi_array_ref(extents_.begin()); |
108 | 108 | } |
109 | 109 | |
110 | 110 | explicit const_multi_array_ref(TPtr base, |
… |
… |
public:
|
125 | 125 | } |
126 | 126 | |
127 | 127 | template <class InputIterator> |
128 | | void assign(InputIterator begin, InputIterator end) { |
| 128 | void assign(InputIterator begin_, InputIterator end_) { |
129 | 129 | boost::function_requires<InputIteratorConcept<InputIterator> >(); |
130 | 130 | |
131 | | InputIterator in_iter = begin; |
| 131 | InputIterator in_iter = begin_; |
132 | 132 | T* out_iter = base_; |
133 | 133 | std::size_t copy_count=0; |
134 | | while (in_iter != end && copy_count < num_elements_) { |
| 134 | while (in_iter != end_ && copy_count < num_elements_) { |
135 | 135 | *out_iter++ = *in_iter++; |
136 | 136 | copy_count++; |
137 | 137 | } |
… |
… |
public:
|
162 | 162 | } |
163 | 163 | |
164 | 164 | template <typename SizeList> |
165 | | void reshape(const SizeList& extents) { |
| 165 | void reshape(const SizeList& extents_) { |
166 | 166 | boost::function_requires< |
167 | 167 | CollectionConcept<SizeList> >(); |
168 | 168 | BOOST_ASSERT(num_elements_ == |
169 | | std::accumulate(extents.begin(),extents.end(), |
| 169 | std::accumulate(extents_.begin(),extents_.end(), |
170 | 170 | size_type(1),std::multiplies<size_type>())); |
171 | 171 | |
172 | | std::copy(extents.begin(),extents.end(),extent_list_.begin()); |
| 172 | std::copy(extents_.begin(),extents_.end(),extent_list_.begin()); |
173 | 173 | this->compute_strides(stride_list_,extent_list_,storage_); |
174 | 174 | |
175 | 175 | origin_offset_ = |
… |
… |
public:
|
209 | 209 | } |
210 | 210 | |
211 | 211 | template <typename IndexList> |
212 | | const element& operator()(IndexList indices) const { |
| 212 | const element& operator()(IndexList indices_) const { |
213 | 213 | boost::function_requires< |
214 | 214 | CollectionConcept<IndexList> >(); |
215 | 215 | return super_type::access_element(boost::type<const element&>(), |
216 | | indices,origin(), |
| 216 | indices_,origin(), |
217 | 217 | shape(),strides(),index_bases()); |
218 | 218 | } |
219 | 219 | |
… |
… |
public:
|
232 | 232 | #endif // BOOST_MSVC |
233 | 233 | typename const_array_view<NDims>::type |
234 | 234 | operator[](const detail::multi_array:: |
235 | | index_gen<NumDims,NDims>& indices) |
| 235 | index_gen<NumDims,NDims>& indices_) |
236 | 236 | const { |
237 | 237 | typedef typename const_array_view<NDims>::type return_type; |
238 | 238 | return |
239 | 239 | super_type::generate_array_view(boost::type<return_type>(), |
240 | | indices, |
| 240 | indices_, |
241 | 241 | shape(), |
242 | 242 | strides(), |
243 | 243 | index_bases(), |
… |
… |
public:
|
328 | 328 | explicit |
329 | 329 | const_multi_array_ref(TPtr base, |
330 | 330 | const storage_order_type& so, |
331 | | const index * index_bases, |
332 | | const size_type* extents) : |
| 331 | const index * index_bases_, |
| 332 | const size_type* extents_) : |
333 | 333 | base_(base), storage_(so), origin_offset_(0), directional_offset_(0) |
334 | 334 | { |
335 | | // If index_bases or extents is null, then initialize the corresponding |
| 335 | // If index_bases_ or extents_ is null, then initialize the corresponding |
336 | 336 | // private data to zeroed lists. |
337 | | if(index_bases) { |
| 337 | if(index_bases_) { |
338 | 338 | boost::detail::multi_array:: |
339 | | copy_n(index_bases,NumDims,index_base_list_.begin()); |
| 339 | copy_n(index_bases_,NumDims,index_base_list_.begin()); |
340 | 340 | } else { |
341 | 341 | std::fill_n(index_base_list_.begin(),NumDims,0); |
342 | 342 | } |
343 | | if(extents) { |
344 | | init_multi_array_ref(extents); |
| 343 | if(extents_) { |
| 344 | init_multi_array_ref(extents_); |
345 | 345 | } else { |
346 | 346 | boost::array<index,NumDims> extent_list; |
347 | 347 | extent_list.assign(0); |
… |
… |
private:
|
375 | 375 | boost::mem_fun_ref(&extent_range::start)); |
376 | 376 | |
377 | 377 | // calculate the extents |
378 | | extent_list extents; |
| 378 | extent_list extents_; |
379 | 379 | std::transform(ranges.ranges_.begin(),ranges.ranges_.end(), |
380 | | extents.begin(), |
| 380 | extents_.begin(), |
381 | 381 | boost::mem_fun_ref(&extent_range::size)); |
382 | 382 | |
383 | | init_multi_array_ref(extents.begin()); |
| 383 | init_multi_array_ref(extents_.begin()); |
384 | 384 | } |
385 | 385 | |
386 | 386 | |
… |
… |
public:
|
446 | 446 | }; |
447 | 447 | |
448 | 448 | template <class ExtentList> |
449 | | explicit multi_array_ref(T* base, const ExtentList& extents) : |
450 | | super_type(base,extents) { |
| 449 | explicit multi_array_ref(T* base, const ExtentList& extents_) : |
| 450 | super_type(base,extents_) { |
451 | 451 | boost::function_requires< |
452 | 452 | CollectionConcept<ExtentList> >(); |
453 | 453 | } |
454 | 454 | |
455 | 455 | template <class ExtentList> |
456 | | explicit multi_array_ref(T* base, const ExtentList& extents, |
| 456 | explicit multi_array_ref(T* base, const ExtentList& extents_, |
457 | 457 | const general_storage_order<NumDims>& so) : |
458 | | super_type(base,extents,so) { |
| 458 | super_type(base,extents_,so) { |
459 | 459 | boost::function_requires< |
460 | 460 | CollectionConcept<ExtentList> >(); |
461 | 461 | } |
… |
… |
public:
|
510 | 510 | element* data() { return super_type::base_; } |
511 | 511 | |
512 | 512 | template <class IndexList> |
513 | | element& operator()(const IndexList& indices) { |
| 513 | element& operator()(const IndexList& indices_) { |
514 | 514 | boost::function_requires< |
515 | 515 | CollectionConcept<IndexList> >(); |
516 | 516 | return super_type::access_element(boost::type<element&>(), |
517 | | indices,origin(), |
| 517 | indices_,origin(), |
518 | 518 | this->shape(),this->strides(), |
519 | 519 | this->index_bases()); |
520 | 520 | } |
… |
… |
public:
|
536 | 536 | #endif // BOOST_MSVC |
537 | 537 | typename array_view<NDims>::type |
538 | 538 | operator[](const detail::multi_array:: |
539 | | index_gen<NumDims,NDims>& indices) { |
| 539 | index_gen<NumDims,NDims>& indices_) { |
540 | 540 | typedef typename array_view<NDims>::type return_type; |
541 | 541 | return |
542 | 542 | super_type::generate_array_view(boost::type<return_type>(), |
543 | | indices, |
| 543 | indices_, |
544 | 544 | this->shape(), |
545 | 545 | this->strides(), |
546 | 546 | this->index_bases(), |
… |
… |
public:
|
577 | 577 | const element* data() const { return super_type::data(); } |
578 | 578 | |
579 | 579 | template <class IndexList> |
580 | | const element& operator()(const IndexList& indices) const { |
| 580 | const element& operator()(const IndexList& indices_) const { |
581 | 581 | boost::function_requires< |
582 | 582 | CollectionConcept<IndexList> >(); |
583 | | return super_type::operator()(indices); |
| 583 | return super_type::operator()(indices_); |
584 | 584 | } |
585 | 585 | |
586 | 586 | const_reference operator[](index idx) const { |
… |
… |
public:
|
598 | 598 | #endif // BOOST_MSVC |
599 | 599 | typename const_array_view<NDims>::type |
600 | 600 | operator[](const detail::multi_array:: |
601 | | index_gen<NumDims,NDims>& indices) |
| 601 | index_gen<NumDims,NDims>& indices_) |
602 | 602 | const { |
603 | | return super_type::operator[](indices); |
| 603 | return super_type::operator[](indices_); |
604 | 604 | } |
605 | 605 | |
606 | 606 | const_iterator begin() const { |
… |
… |
protected:
|
623 | 623 | // This is only supplied to support multi_array's default constructor |
624 | 624 | explicit multi_array_ref(T* base, |
625 | 625 | const storage_order_type& so, |
626 | | const index* index_bases, |
627 | | const size_type* extents) : |
628 | | super_type(base,so,index_bases,extents) { } |
| 626 | const index* index_bases_, |
| 627 | const size_type* extents_) : |
| 628 | super_type(base,so,index_bases_,extents_) { } |
629 | 629 | |
630 | 630 | }; |
631 | 631 | |
diff --git a/include/boost/multi_array/storage_order.hpp b/include/boost/multi_array/storage_order.hpp
index 3eb7136..219f24d 100644
a
|
b
|
namespace boost {
|
34 | 34 | public: |
35 | 35 | typedef detail::multi_array::size_type size_type; |
36 | 36 | template <typename OrderingIter, typename AscendingIter> |
37 | | general_storage_order(OrderingIter ordering, |
38 | | AscendingIter ascending) { |
39 | | boost::detail::multi_array::copy_n(ordering,NumDims,ordering_.begin()); |
40 | | boost::detail::multi_array::copy_n(ascending,NumDims,ascending_.begin()); |
| 37 | general_storage_order(OrderingIter i_ordering, |
| 38 | AscendingIter i_ascending) { |
| 39 | boost::detail::multi_array::copy_n(i_ordering,NumDims,ordering_.begin()); |
| 40 | boost::detail::multi_array::copy_n(i_ascending,NumDims,ascending_.begin()); |
41 | 41 | } |
42 | 42 | |
43 | 43 | // RG - ideally these would not be necessary, but some compilers |
diff --git a/include/boost/multi_array/subarray.hpp b/include/boost/multi_array/subarray.hpp
index a498916..cc8b7f4 100644
a
|
b
|
public: // Should be protected
|
181 | 181 | |
182 | 182 | const_sub_array (TPtr base, |
183 | 183 | const size_type* extents, |
184 | | const index* strides, |
| 184 | const index* i_strides, |
185 | 185 | const index* index_base) : |
186 | | base_(base), extents_(extents), strides_(strides), |
| 186 | base_(base), extents_(extents), strides_(i_strides), |
187 | 187 | index_base_(index_base) { |
188 | 188 | } |
189 | 189 | |
… |
… |
public: // should be private
|
369 | 369 | |
370 | 370 | sub_array (T* base, |
371 | 371 | const size_type* extents, |
372 | | const index* strides, |
| 372 | const index* _strides, |
373 | 373 | const index* index_base) : |
374 | | super_type(base,extents,strides,index_base) { |
| 374 | super_type(base,extents,_strides,index_base) { |
375 | 375 | } |
376 | 376 | |
377 | 377 | }; |
diff --git a/include/boost/multi_array/view.hpp b/include/boost/multi_array/view.hpp
index d11e260..2f692a8 100644
a
|
b
|
public: // should be protected
|
232 | 232 | template <typename ExtentList, typename Index> |
233 | 233 | explicit const_multi_array_view(TPtr base, |
234 | 234 | const ExtentList& extents, |
235 | | const boost::array<Index,NumDims>& strides): |
| 235 | const boost::array<Index,NumDims>& strides_): |
236 | 236 | base_(base), origin_offset_(0) { |
237 | 237 | |
238 | 238 | index_base_list_.assign(0); |
… |
… |
public: // should be protected
|
241 | 241 | boost::detail::multi_array:: |
242 | 242 | copy_n(extents.begin(),NumDims,extent_list_.begin()); |
243 | 243 | boost::detail::multi_array:: |
244 | | copy_n(strides.begin(),NumDims,stride_list_.begin()); |
| 244 | copy_n(strides_.begin(),NumDims,stride_list_.begin()); |
245 | 245 | |
246 | 246 | // Calculate the array size |
247 | 247 | num_elements_ = std::accumulate(extent_list_.begin(),extent_list_.end(), |
… |
… |
public: // should be private
|
442 | 442 | template <typename ExtentList, typename Index> |
443 | 443 | explicit multi_array_view(T* base, |
444 | 444 | const ExtentList& extents, |
445 | | const boost::array<Index,NumDims>& strides) : |
446 | | super_type(base,extents,strides) { } |
| 445 | const boost::array<Index,NumDims>& _strides) : |
| 446 | super_type(base,extents,_strides) { } |
447 | 447 | |
448 | 448 | }; |
449 | 449 | |