| 124 | |
| 125 | template<typename QuaternionType> |
| 126 | void check_stdlist_quaternion(const QuaternionType&) |
| 127 | { |
| 128 | typedef typename QuaternionType::Coefficients Coefficients; |
| 129 | QuaternionType x(Coefficients::Random()), y(Coefficients::Random()); |
| 130 | std::list<QuaternionType> v(10), w(20, y); |
| 131 | typename std::list<QuaternionType>::iterator itv = get(v, 5); |
| 132 | typename std::list<QuaternionType>::iterator itw = get(w, 6); |
| 133 | *itv = x; |
| 134 | *itw = *itv; |
| 135 | VERIFY_IS_APPROX(*itw, *itv); |
| 136 | v = w; |
| 137 | itv = v.begin(); |
| 138 | itw = w.begin(); |
| 139 | for(int i = 0; i < 20; i++) |
| 140 | { |
| 141 | VERIFY_IS_APPROX(*itw, *itv); |
| 142 | ++itv; |
| 143 | ++itw; |
| 144 | } |
| 145 | |
| 146 | v.resize(21); |
| 147 | set(v, 20, x); |
| 148 | VERIFY_IS_APPROX(*get(v, 20), x); |
| 149 | v.resize(22,y); |
| 150 | VERIFY_IS_APPROX(*get(v, 21), y); |
| 151 | v.push_back(x); |
| 152 | VERIFY_IS_APPROX(*get(v, 22), x); |
| 153 | |
| 154 | // do a lot of push_back such that the list gets internally resized |
| 155 | // (with memory reallocation) |
| 156 | QuaternionType* ref = &(*get(w, 0)); |
| 157 | for(int i=0; i<30 || ((ref==&(*get(w, 0))) && i<300); ++i) |
| 158 | v.push_back(*get(w, i%w.size())); |
| 159 | for(unsigned int i=23; i<v.size(); ++i) |
| 160 | { |
| 161 | VERIFY(get(v, i)->coeffs()==get(w, (i-23)%w.size())->coeffs()); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | void test_stdlist_overload() |
| 166 | { |