1 /* PR 16688. Test provided by Wolfgang Bangerth. The alias analyzer
2 was aborting when trying to group aliases. */
4 /* { dg-do compile } */
5 /* { dg-options "-O2" } */
8 struct iterator_traits;
10 template<typename _Tp>
11 struct iterator_traits<_Tp*> {
12 typedef _Tp& reference;
15 template<typename _Iterator> struct NI {
18 typedef typename iterator_traits<_Iterator>::reference reference;
22 NI(const _Iterator& __i) : current(__i) { }
24 reference operator*() const { return *current; }
26 NI& operator++() { return *this; }
28 const _Iterator& base() const { return current; }
31 template<typename _IteratorL, typename _IteratorR>
33 operator-(const NI<_IteratorL>& __lhs,
34 const NI<_IteratorR>& __rhs)
35 { return __lhs.base() - __rhs.base(); }
38 template<typename _II, typename _OI>
40 __copy_aux(_II __first, _II __last, _OI __result)
44 copy(_II __first, _II __last, _OI __result)
46 for (; __first != __last; ++__result, ++__first)
52 return __copy::copy(__first, __last, __result);
57 template<typename _II, typename _OI>
59 copy_n(_II __first, _II __last, _OI __result)
61 return __copy_aux(__first, __last, __result);
64 template<typename _InputIterator, typename _OutputIterator>
65 inline _OutputIterator
66 copy(_InputIterator __first, _InputIterator __last,
67 _OutputIterator __result)
69 return __copy_normal::copy_n(__first, __last, __result);
72 template <typename T, typename U, typename V>
73 void uninitialized_fill_n(T,U,V);
76 template<typename _Tp>
82 _Vector_impl() : start(0), finish(0), end_of_storage(0)
86 _Vector_base(unsigned __n) {
87 impl.start = allocate(__n);
88 impl.finish = impl.start;
89 impl.end_of_storage = impl.start + __n;
93 deallocate(impl.start,
94 impl.end_of_storage - impl.start);
97 _Tp* allocate(unsigned __n);
99 void deallocate(_Tp* __p, unsigned __n);
101 NI<_Tp*> begin() { return NI<_Tp*> (impl.start); }
105 template<typename _Tp>
106 struct vector : _Vector_base<_Tp>
109 : _Vector_base<_Tp>(__n)
111 uninitialized_fill_n(this->impl.start, __n, _Tp());
120 Tensor (const Tensor &);
127 Tensor::Tensor (const Tensor &p)
129 for (unsigned int i=0; i<2; ++i)
130 values[i] = p.values[i];
136 typedef void * AccessorData;
138 void copy_from (const TriaAccessor &);
139 void operator = (const TriaAccessor *);
141 TriaAccessor & operator = (const TriaAccessor &);
143 bool operator == (const TriaAccessor &) const;
145 bool operator != (const TriaAccessor &) const;
156 inline int TriaAccessor::state () const {
157 if ((present_level>=0) && (present_index>=0))
160 if ((present_level==-1) && (present_index==-1))
168 void TriaAccessor::operator ++ () {
169 ++this->present_index;
171 while (this->present_index >=
172 static_cast<int>(*this->levels[this->present_level]))
174 ++this->present_level;
175 this->present_index = 0;
177 if (this->present_level >= static_cast<int>(1))
180 this->present_level = this->present_index = -1;
186 struct MGDoFObjectAccessor : TriaAccessor {};
190 struct TriaRawIterator
194 TriaRawIterator (const TriaRawIterator &);
195 TriaRawIterator (const MGDoFObjectAccessor &a);
196 const MGDoFObjectAccessor & operator * () const;
198 MGDoFObjectAccessor & operator * ();
199 const MGDoFObjectAccessor * operator -> () const;
201 MGDoFObjectAccessor * operator -> ();
203 TriaRawIterator & operator = (const TriaRawIterator &);
205 bool operator == (const TriaRawIterator &) const;
206 bool operator != (const TriaRawIterator &) const;
207 bool operator < (const TriaRawIterator &) const;
208 MGDoFObjectAccessor accessor;
210 TriaRawIterator & operator ++ ();
213 struct TriaIterator : TriaRawIterator
217 TriaIterator (const TriaIterator &i);
220 operator = (const TriaIterator &);
223 operator = (const TriaRawIterator &);
228 TriaRawIterator::TriaRawIterator (const TriaRawIterator &i) :
229 accessor (i.accessor) {}
232 TriaIterator::TriaIterator (const TriaIterator &i) :
233 TriaRawIterator (static_cast<TriaRawIterator >(i)) {}
236 TriaRawIterator & TriaRawIterator::operator ++ () {
237 while (++accessor, (this->accessor.state() == 0))
238 if (this->accessor.used() == true)
244 Comp (const Tensor &dir) : dir(dir) {}
246 bool operator () (const TriaIterator &c1, const TriaIterator &c2) const;
251 template<typename Iter>
252 void x1(Iter first, Iter last, int i, Comp comp)
254 x1(Iter(), last, i, comp);
257 template<typename Iter>
258 inline void x2(Iter first, Iter last, Comp comp)
260 if (first.base() != last.base())
261 x1(first, last, (last - first), comp);
264 void downstream_dg (const Tensor& direction)
266 vector<TriaIterator> ordered_cells(13);
267 const Comp comparator(direction);
269 TriaIterator begin, end;
271 copy (begin, end, ordered_cells.begin());
272 x2 (ordered_cells.begin(), ordered_cells.begin(), comparator);