Mercurial > hg > sv-dependency-builds
comparison win64-msvc/include/capnp/list.h @ 148:b4bfdf10c4b3
Update Win64 capnp builds to v0.6
| author | Chris Cannam <cannam@all-day-breakfast.com> |
|---|---|
| date | Mon, 22 May 2017 18:56:49 +0100 |
| parents | 42a73082be24 |
| children |
comparison
equal
deleted
inserted
replaced
| 147:45360b968bf4 | 148:b4bfdf10c4b3 |
|---|---|
| 112 typedef List<T> Reads; | 112 typedef List<T> Reads; |
| 113 | 113 |
| 114 inline Reader(): reader(_::elementSizeForType<T>()) {} | 114 inline Reader(): reader(_::elementSizeForType<T>()) {} |
| 115 inline explicit Reader(_::ListReader reader): reader(reader) {} | 115 inline explicit Reader(_::ListReader reader): reader(reader) {} |
| 116 | 116 |
| 117 inline uint size() const { return reader.size() / ELEMENTS; } | 117 inline uint size() const { return unbound(reader.size() / ELEMENTS); } |
| 118 inline T operator[](uint index) const { | 118 inline T operator[](uint index) const { |
| 119 KJ_IREQUIRE(index < size()); | 119 KJ_IREQUIRE(index < size()); |
| 120 return reader.template getDataElement<T>(index * ELEMENTS); | 120 return reader.template getDataElement<T>(bounded(index) * ELEMENTS); |
| 121 } | 121 } |
| 122 | 122 |
| 123 typedef _::IndexingIterator<const Reader, T> Iterator; | 123 typedef _::IndexingIterator<const Reader, T> Iterator; |
| 124 inline Iterator begin() const { return Iterator(this, 0); } | 124 inline Iterator begin() const { return Iterator(this, 0); } |
| 125 inline Iterator end() const { return Iterator(this, size()); } | 125 inline Iterator end() const { return Iterator(this, size()); } |
| 138 class Builder { | 138 class Builder { |
| 139 public: | 139 public: |
| 140 typedef List<T> Builds; | 140 typedef List<T> Builds; |
| 141 | 141 |
| 142 inline Builder(): builder(_::elementSizeForType<T>()) {} | 142 inline Builder(): builder(_::elementSizeForType<T>()) {} |
| 143 inline Builder(decltype(nullptr)) {} | 143 inline Builder(decltype(nullptr)): Builder() {} |
| 144 inline explicit Builder(_::ListBuilder builder): builder(builder) {} | 144 inline explicit Builder(_::ListBuilder builder): builder(builder) {} |
| 145 | 145 |
| 146 inline operator Reader() const { return Reader(builder.asReader()); } | 146 inline operator Reader() const { return Reader(builder.asReader()); } |
| 147 inline Reader asReader() const { return Reader(builder.asReader()); } | 147 inline Reader asReader() const { return Reader(builder.asReader()); } |
| 148 | 148 |
| 149 inline uint size() const { return builder.size() / ELEMENTS; } | 149 inline uint size() const { return unbound(builder.size() / ELEMENTS); } |
| 150 inline T operator[](uint index) { | 150 inline T operator[](uint index) { |
| 151 KJ_IREQUIRE(index < size()); | 151 KJ_IREQUIRE(index < size()); |
| 152 return builder.template getDataElement<T>(index * ELEMENTS); | 152 return builder.template getDataElement<T>(bounded(index) * ELEMENTS); |
| 153 } | 153 } |
| 154 inline void set(uint index, T value) { | 154 inline void set(uint index, T value) { |
| 155 // Alas, it is not possible to make operator[] return a reference to which you can assign, | 155 // Alas, it is not possible to make operator[] return a reference to which you can assign, |
| 156 // since the encoded representation does not necessarily match the compiler's representation | 156 // since the encoded representation does not necessarily match the compiler's representation |
| 157 // of the type. We can't even return a clever class that implements operator T() and | 157 // of the type. We can't even return a clever class that implements operator T() and |
| 158 // operator=() because it will lead to surprising behavior when using type inference (e.g. | 158 // operator=() because it will lead to surprising behavior when using type inference (e.g. |
| 159 // calling a template function with inferred argument types, or using "auto" or "decltype"). | 159 // calling a template function with inferred argument types, or using "auto" or "decltype"). |
| 160 | 160 |
| 161 builder.template setDataElement<T>(index * ELEMENTS, value); | 161 builder.template setDataElement<T>(bounded(index) * ELEMENTS, value); |
| 162 } | 162 } |
| 163 | 163 |
| 164 typedef _::IndexingIterator<Builder, T> Iterator; | 164 typedef _::IndexingIterator<Builder, T> Iterator; |
| 165 inline Iterator begin() { return Iterator(this, 0); } | 165 inline Iterator begin() { return Iterator(this, 0); } |
| 166 inline Iterator end() { return Iterator(this, size()); } | 166 inline Iterator end() { return Iterator(this, size()); } |
| 176 | 176 |
| 177 class Pipeline {}; | 177 class Pipeline {}; |
| 178 | 178 |
| 179 private: | 179 private: |
| 180 inline static _::ListBuilder initPointer(_::PointerBuilder builder, uint size) { | 180 inline static _::ListBuilder initPointer(_::PointerBuilder builder, uint size) { |
| 181 return builder.initList(_::elementSizeForType<T>(), size * ELEMENTS); | 181 return builder.initList(_::elementSizeForType<T>(), bounded(size) * ELEMENTS); |
| 182 } | 182 } |
| 183 inline static _::ListBuilder getFromPointer(_::PointerBuilder builder, const word* defaultValue) { | 183 inline static _::ListBuilder getFromPointer(_::PointerBuilder builder, const word* defaultValue) { |
| 184 return builder.getList(_::elementSizeForType<T>(), defaultValue); | 184 return builder.getList(_::elementSizeForType<T>(), defaultValue); |
| 185 } | 185 } |
| 186 inline static _::ListReader getFromPointer( | 186 inline static _::ListReader getFromPointer( |
| 208 typedef List<T> Reads; | 208 typedef List<T> Reads; |
| 209 | 209 |
| 210 inline Reader(): reader(ElementSize::INLINE_COMPOSITE) {} | 210 inline Reader(): reader(ElementSize::INLINE_COMPOSITE) {} |
| 211 inline explicit Reader(_::ListReader reader): reader(reader) {} | 211 inline explicit Reader(_::ListReader reader): reader(reader) {} |
| 212 | 212 |
| 213 inline uint size() const { return reader.size() / ELEMENTS; } | 213 inline uint size() const { return unbound(reader.size() / ELEMENTS); } |
| 214 inline typename T::Reader operator[](uint index) const { | 214 inline typename T::Reader operator[](uint index) const { |
| 215 KJ_IREQUIRE(index < size()); | 215 KJ_IREQUIRE(index < size()); |
| 216 return typename T::Reader(reader.getStructElement(index * ELEMENTS)); | 216 return typename T::Reader(reader.getStructElement(bounded(index) * ELEMENTS)); |
| 217 } | 217 } |
| 218 | 218 |
| 219 typedef _::IndexingIterator<const Reader, typename T::Reader> Iterator; | 219 typedef _::IndexingIterator<const Reader, typename T::Reader> Iterator; |
| 220 inline Iterator begin() const { return Iterator(this, 0); } | 220 inline Iterator begin() const { return Iterator(this, 0); } |
| 221 inline Iterator end() const { return Iterator(this, size()); } | 221 inline Iterator end() const { return Iterator(this, size()); } |
| 234 class Builder { | 234 class Builder { |
| 235 public: | 235 public: |
| 236 typedef List<T> Builds; | 236 typedef List<T> Builds; |
| 237 | 237 |
| 238 inline Builder(): builder(ElementSize::INLINE_COMPOSITE) {} | 238 inline Builder(): builder(ElementSize::INLINE_COMPOSITE) {} |
| 239 inline Builder(decltype(nullptr)) {} | 239 inline Builder(decltype(nullptr)): Builder() {} |
| 240 inline explicit Builder(_::ListBuilder builder): builder(builder) {} | 240 inline explicit Builder(_::ListBuilder builder): builder(builder) {} |
| 241 | 241 |
| 242 inline operator Reader() const { return Reader(builder.asReader()); } | 242 inline operator Reader() const { return Reader(builder.asReader()); } |
| 243 inline Reader asReader() const { return Reader(builder.asReader()); } | 243 inline Reader asReader() const { return Reader(builder.asReader()); } |
| 244 | 244 |
| 245 inline uint size() const { return builder.size() / ELEMENTS; } | 245 inline uint size() const { return unbound(builder.size() / ELEMENTS); } |
| 246 inline typename T::Builder operator[](uint index) { | 246 inline typename T::Builder operator[](uint index) { |
| 247 KJ_IREQUIRE(index < size()); | 247 KJ_IREQUIRE(index < size()); |
| 248 return typename T::Builder(builder.getStructElement(index * ELEMENTS)); | 248 return typename T::Builder(builder.getStructElement(bounded(index) * ELEMENTS)); |
| 249 } | 249 } |
| 250 | 250 |
| 251 inline void adoptWithCaveats(uint index, Orphan<T>&& orphan) { | 251 inline void adoptWithCaveats(uint index, Orphan<T>&& orphan) { |
| 252 // Mostly behaves like you'd expect `adopt` to behave, but with two caveats originating from | 252 // Mostly behaves like you'd expect `adopt` to behave, but with two caveats originating from |
| 253 // the fact that structs in a struct list are allocated inline rather than by pointer: | 253 // the fact that structs in a struct list are allocated inline rather than by pointer: |
| 261 KJ_IREQUIRE(index < size()); | 261 KJ_IREQUIRE(index < size()); |
| 262 | 262 |
| 263 // We pass a zero-valued StructSize to asStruct() because we do not want the struct to be | 263 // We pass a zero-valued StructSize to asStruct() because we do not want the struct to be |
| 264 // expanded under any circumstances. We're just going to throw it away anyway, and | 264 // expanded under any circumstances. We're just going to throw it away anyway, and |
| 265 // transferContentFrom() already carefully compares the struct sizes before transferring. | 265 // transferContentFrom() already carefully compares the struct sizes before transferring. |
| 266 builder.getStructElement(index * ELEMENTS).transferContentFrom( | 266 builder.getStructElement(bounded(index) * ELEMENTS).transferContentFrom( |
| 267 orphan.builder.asStruct(_::StructSize(0 * WORDS, 0 * POINTERS))); | 267 orphan.builder.asStruct(_::StructSize(ZERO * WORDS, ZERO * POINTERS))); |
| 268 } | 268 } |
| 269 inline void setWithCaveats(uint index, const typename T::Reader& reader) { | 269 inline void setWithCaveats(uint index, const typename T::Reader& reader) { |
| 270 // Mostly behaves like you'd expect `set` to behave, but with a caveat originating from | 270 // Mostly behaves like you'd expect `set` to behave, but with a caveat originating from |
| 271 // the fact that structs in a struct list are allocated inline rather than by pointer: | 271 // the fact that structs in a struct list are allocated inline rather than by pointer: |
| 272 // If the source struct is larger than the target struct -- say, because the source was built | 272 // If the source struct is larger than the target struct -- say, because the source was built |
| 276 // Note: If you are trying to concatenate some lists, use Orphanage::newOrphanConcat() to | 276 // Note: If you are trying to concatenate some lists, use Orphanage::newOrphanConcat() to |
| 277 // do it without losing any data in case the source lists come from a newer version of the | 277 // do it without losing any data in case the source lists come from a newer version of the |
| 278 // protocol. (Plus, it's easier to use anyhow.) | 278 // protocol. (Plus, it's easier to use anyhow.) |
| 279 | 279 |
| 280 KJ_IREQUIRE(index < size()); | 280 KJ_IREQUIRE(index < size()); |
| 281 builder.getStructElement(index * ELEMENTS).copyContentFrom(reader._reader); | 281 builder.getStructElement(bounded(index) * ELEMENTS).copyContentFrom(reader._reader); |
| 282 } | 282 } |
| 283 | 283 |
| 284 // There are no init(), set(), adopt(), or disown() methods for lists of structs because the | 284 // There are no init(), set(), adopt(), or disown() methods for lists of structs because the |
| 285 // elements of the list are inlined and are initialized when the list is initialized. This | 285 // elements of the list are inlined and are initialized when the list is initialized. This |
| 286 // means that init() would be redundant, and set() would risk data loss if the input struct | 286 // means that init() would be redundant, and set() would risk data loss if the input struct |
| 301 | 301 |
| 302 class Pipeline {}; | 302 class Pipeline {}; |
| 303 | 303 |
| 304 private: | 304 private: |
| 305 inline static _::ListBuilder initPointer(_::PointerBuilder builder, uint size) { | 305 inline static _::ListBuilder initPointer(_::PointerBuilder builder, uint size) { |
| 306 return builder.initStructList(size * ELEMENTS, _::structSize<T>()); | 306 return builder.initStructList(bounded(size) * ELEMENTS, _::structSize<T>()); |
| 307 } | 307 } |
| 308 inline static _::ListBuilder getFromPointer(_::PointerBuilder builder, const word* defaultValue) { | 308 inline static _::ListBuilder getFromPointer(_::PointerBuilder builder, const word* defaultValue) { |
| 309 return builder.getStructList(_::structSize<T>(), defaultValue); | 309 return builder.getStructList(_::structSize<T>(), defaultValue); |
| 310 } | 310 } |
| 311 inline static _::ListReader getFromPointer( | 311 inline static _::ListReader getFromPointer( |
| 330 typedef List<List<T>> Reads; | 330 typedef List<List<T>> Reads; |
| 331 | 331 |
| 332 inline Reader(): reader(ElementSize::POINTER) {} | 332 inline Reader(): reader(ElementSize::POINTER) {} |
| 333 inline explicit Reader(_::ListReader reader): reader(reader) {} | 333 inline explicit Reader(_::ListReader reader): reader(reader) {} |
| 334 | 334 |
| 335 inline uint size() const { return reader.size() / ELEMENTS; } | 335 inline uint size() const { return unbound(reader.size() / ELEMENTS); } |
| 336 inline typename List<T>::Reader operator[](uint index) const { | 336 inline typename List<T>::Reader operator[](uint index) const { |
| 337 KJ_IREQUIRE(index < size()); | 337 KJ_IREQUIRE(index < size()); |
| 338 return typename List<T>::Reader( | 338 return typename List<T>::Reader(_::PointerHelpers<List<T>>::get( |
| 339 _::PointerHelpers<List<T>>::get(reader.getPointerElement(index * ELEMENTS))); | 339 reader.getPointerElement(bounded(index) * ELEMENTS))); |
| 340 } | 340 } |
| 341 | 341 |
| 342 typedef _::IndexingIterator<const Reader, typename List<T>::Reader> Iterator; | 342 typedef _::IndexingIterator<const Reader, typename List<T>::Reader> Iterator; |
| 343 inline Iterator begin() const { return Iterator(this, 0); } | 343 inline Iterator begin() const { return Iterator(this, 0); } |
| 344 inline Iterator end() const { return Iterator(this, size()); } | 344 inline Iterator end() const { return Iterator(this, size()); } |
| 357 class Builder { | 357 class Builder { |
| 358 public: | 358 public: |
| 359 typedef List<List<T>> Builds; | 359 typedef List<List<T>> Builds; |
| 360 | 360 |
| 361 inline Builder(): builder(ElementSize::POINTER) {} | 361 inline Builder(): builder(ElementSize::POINTER) {} |
| 362 inline Builder(decltype(nullptr)) {} | 362 inline Builder(decltype(nullptr)): Builder() {} |
| 363 inline explicit Builder(_::ListBuilder builder): builder(builder) {} | 363 inline explicit Builder(_::ListBuilder builder): builder(builder) {} |
| 364 | 364 |
| 365 inline operator Reader() const { return Reader(builder.asReader()); } | 365 inline operator Reader() const { return Reader(builder.asReader()); } |
| 366 inline Reader asReader() const { return Reader(builder.asReader()); } | 366 inline Reader asReader() const { return Reader(builder.asReader()); } |
| 367 | 367 |
| 368 inline uint size() const { return builder.size() / ELEMENTS; } | 368 inline uint size() const { return unbound(builder.size() / ELEMENTS); } |
| 369 inline typename List<T>::Builder operator[](uint index) { | 369 inline typename List<T>::Builder operator[](uint index) { |
| 370 KJ_IREQUIRE(index < size()); | 370 KJ_IREQUIRE(index < size()); |
| 371 return typename List<T>::Builder( | 371 return typename List<T>::Builder(_::PointerHelpers<List<T>>::get( |
| 372 _::PointerHelpers<List<T>>::get(builder.getPointerElement(index * ELEMENTS))); | 372 builder.getPointerElement(bounded(index) * ELEMENTS))); |
| 373 } | 373 } |
| 374 inline typename List<T>::Builder init(uint index, uint size) { | 374 inline typename List<T>::Builder init(uint index, uint size) { |
| 375 KJ_IREQUIRE(index < this->size()); | 375 KJ_IREQUIRE(index < this->size()); |
| 376 return typename List<T>::Builder( | 376 return typename List<T>::Builder(_::PointerHelpers<List<T>>::init( |
| 377 _::PointerHelpers<List<T>>::init(builder.getPointerElement(index * ELEMENTS), size)); | 377 builder.getPointerElement(bounded(index) * ELEMENTS), size)); |
| 378 } | 378 } |
| 379 inline void set(uint index, typename List<T>::Reader value) { | 379 inline void set(uint index, typename List<T>::Reader value) { |
| 380 KJ_IREQUIRE(index < size()); | 380 KJ_IREQUIRE(index < size()); |
| 381 builder.getPointerElement(index * ELEMENTS).setList(value.reader); | 381 builder.getPointerElement(bounded(index) * ELEMENTS).setList(value.reader); |
| 382 } | 382 } |
| 383 void set(uint index, std::initializer_list<ReaderFor<T>> value) { | 383 void set(uint index, std::initializer_list<ReaderFor<T>> value) { |
| 384 KJ_IREQUIRE(index < size()); | 384 KJ_IREQUIRE(index < size()); |
| 385 auto l = init(index, value.size()); | 385 auto l = init(index, value.size()); |
| 386 uint i = 0; | 386 uint i = 0; |
| 388 l.set(i++, element); | 388 l.set(i++, element); |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 inline void adopt(uint index, Orphan<T>&& value) { | 391 inline void adopt(uint index, Orphan<T>&& value) { |
| 392 KJ_IREQUIRE(index < size()); | 392 KJ_IREQUIRE(index < size()); |
| 393 builder.getPointerElement(index * ELEMENTS).adopt(kj::mv(value.builder)); | 393 builder.getPointerElement(bounded(index) * ELEMENTS).adopt(kj::mv(value.builder)); |
| 394 } | 394 } |
| 395 inline Orphan<T> disown(uint index) { | 395 inline Orphan<T> disown(uint index) { |
| 396 KJ_IREQUIRE(index < size()); | 396 KJ_IREQUIRE(index < size()); |
| 397 return Orphan<T>(builder.getPointerElement(index * ELEMENTS).disown()); | 397 return Orphan<T>(builder.getPointerElement(bounded(index) * ELEMENTS).disown()); |
| 398 } | 398 } |
| 399 | 399 |
| 400 typedef _::IndexingIterator<Builder, typename List<T>::Builder> Iterator; | 400 typedef _::IndexingIterator<Builder, typename List<T>::Builder> Iterator; |
| 401 inline Iterator begin() { return Iterator(this, 0); } | 401 inline Iterator begin() { return Iterator(this, 0); } |
| 402 inline Iterator end() { return Iterator(this, size()); } | 402 inline Iterator end() { return Iterator(this, size()); } |
| 412 | 412 |
| 413 class Pipeline {}; | 413 class Pipeline {}; |
| 414 | 414 |
| 415 private: | 415 private: |
| 416 inline static _::ListBuilder initPointer(_::PointerBuilder builder, uint size) { | 416 inline static _::ListBuilder initPointer(_::PointerBuilder builder, uint size) { |
| 417 return builder.initList(ElementSize::POINTER, size * ELEMENTS); | 417 return builder.initList(ElementSize::POINTER, bounded(size) * ELEMENTS); |
| 418 } | 418 } |
| 419 inline static _::ListBuilder getFromPointer(_::PointerBuilder builder, const word* defaultValue) { | 419 inline static _::ListBuilder getFromPointer(_::PointerBuilder builder, const word* defaultValue) { |
| 420 return builder.getList(ElementSize::POINTER, defaultValue); | 420 return builder.getList(ElementSize::POINTER, defaultValue); |
| 421 } | 421 } |
| 422 inline static _::ListReader getFromPointer( | 422 inline static _::ListReader getFromPointer( |
| 439 typedef List<T> Reads; | 439 typedef List<T> Reads; |
| 440 | 440 |
| 441 inline Reader(): reader(ElementSize::POINTER) {} | 441 inline Reader(): reader(ElementSize::POINTER) {} |
| 442 inline explicit Reader(_::ListReader reader): reader(reader) {} | 442 inline explicit Reader(_::ListReader reader): reader(reader) {} |
| 443 | 443 |
| 444 inline uint size() const { return reader.size() / ELEMENTS; } | 444 inline uint size() const { return unbound(reader.size() / ELEMENTS); } |
| 445 inline typename T::Reader operator[](uint index) const { | 445 inline typename T::Reader operator[](uint index) const { |
| 446 KJ_IREQUIRE(index < size()); | 446 KJ_IREQUIRE(index < size()); |
| 447 return reader.getPointerElement(index * ELEMENTS).template getBlob<T>(nullptr, 0 * BYTES); | 447 return reader.getPointerElement(bounded(index) * ELEMENTS) |
| 448 .template getBlob<T>(nullptr, ZERO * BYTES); | |
| 448 } | 449 } |
| 449 | 450 |
| 450 typedef _::IndexingIterator<const Reader, typename T::Reader> Iterator; | 451 typedef _::IndexingIterator<const Reader, typename T::Reader> Iterator; |
| 451 inline Iterator begin() const { return Iterator(this, 0); } | 452 inline Iterator begin() const { return Iterator(this, 0); } |
| 452 inline Iterator end() const { return Iterator(this, size()); } | 453 inline Iterator end() const { return Iterator(this, size()); } |
| 465 class Builder { | 466 class Builder { |
| 466 public: | 467 public: |
| 467 typedef List<T> Builds; | 468 typedef List<T> Builds; |
| 468 | 469 |
| 469 inline Builder(): builder(ElementSize::POINTER) {} | 470 inline Builder(): builder(ElementSize::POINTER) {} |
| 470 inline Builder(decltype(nullptr)) {} | 471 inline Builder(decltype(nullptr)): Builder() {} |
| 471 inline explicit Builder(_::ListBuilder builder): builder(builder) {} | 472 inline explicit Builder(_::ListBuilder builder): builder(builder) {} |
| 472 | 473 |
| 473 inline operator Reader() const { return Reader(builder.asReader()); } | 474 inline operator Reader() const { return Reader(builder.asReader()); } |
| 474 inline Reader asReader() const { return Reader(builder.asReader()); } | 475 inline Reader asReader() const { return Reader(builder.asReader()); } |
| 475 | 476 |
| 476 inline uint size() const { return builder.size() / ELEMENTS; } | 477 inline uint size() const { return unbound(builder.size() / ELEMENTS); } |
| 477 inline typename T::Builder operator[](uint index) { | 478 inline typename T::Builder operator[](uint index) { |
| 478 KJ_IREQUIRE(index < size()); | 479 KJ_IREQUIRE(index < size()); |
| 479 return builder.getPointerElement(index * ELEMENTS).template getBlob<T>(nullptr, 0 * BYTES); | 480 return builder.getPointerElement(bounded(index) * ELEMENTS) |
| 481 .template getBlob<T>(nullptr, ZERO * BYTES); | |
| 480 } | 482 } |
| 481 inline void set(uint index, typename T::Reader value) { | 483 inline void set(uint index, typename T::Reader value) { |
| 482 KJ_IREQUIRE(index < size()); | 484 KJ_IREQUIRE(index < size()); |
| 483 builder.getPointerElement(index * ELEMENTS).template setBlob<T>(value); | 485 builder.getPointerElement(bounded(index) * ELEMENTS).template setBlob<T>(value); |
| 484 } | 486 } |
| 485 inline typename T::Builder init(uint index, uint size) { | 487 inline typename T::Builder init(uint index, uint size) { |
| 486 KJ_IREQUIRE(index < this->size()); | 488 KJ_IREQUIRE(index < this->size()); |
| 487 return builder.getPointerElement(index * ELEMENTS).template initBlob<T>(size * BYTES); | 489 return builder.getPointerElement(bounded(index) * ELEMENTS) |
| 490 .template initBlob<T>(bounded(size) * BYTES); | |
| 488 } | 491 } |
| 489 inline void adopt(uint index, Orphan<T>&& value) { | 492 inline void adopt(uint index, Orphan<T>&& value) { |
| 490 KJ_IREQUIRE(index < size()); | 493 KJ_IREQUIRE(index < size()); |
| 491 builder.getPointerElement(index * ELEMENTS).adopt(kj::mv(value.builder)); | 494 builder.getPointerElement(bounded(index) * ELEMENTS).adopt(kj::mv(value.builder)); |
| 492 } | 495 } |
| 493 inline Orphan<T> disown(uint index) { | 496 inline Orphan<T> disown(uint index) { |
| 494 KJ_IREQUIRE(index < size()); | 497 KJ_IREQUIRE(index < size()); |
| 495 return Orphan<T>(builder.getPointerElement(index * ELEMENTS).disown()); | 498 return Orphan<T>(builder.getPointerElement(bounded(index) * ELEMENTS).disown()); |
| 496 } | 499 } |
| 497 | 500 |
| 498 typedef _::IndexingIterator<Builder, typename T::Builder> Iterator; | 501 typedef _::IndexingIterator<Builder, typename T::Builder> Iterator; |
| 499 inline Iterator begin() { return Iterator(this, 0); } | 502 inline Iterator begin() { return Iterator(this, 0); } |
| 500 inline Iterator end() { return Iterator(this, size()); } | 503 inline Iterator end() { return Iterator(this, size()); } |
| 510 | 513 |
| 511 class Pipeline {}; | 514 class Pipeline {}; |
| 512 | 515 |
| 513 private: | 516 private: |
| 514 inline static _::ListBuilder initPointer(_::PointerBuilder builder, uint size) { | 517 inline static _::ListBuilder initPointer(_::PointerBuilder builder, uint size) { |
| 515 return builder.initList(ElementSize::POINTER, size * ELEMENTS); | 518 return builder.initList(ElementSize::POINTER, bounded(size) * ELEMENTS); |
| 516 } | 519 } |
| 517 inline static _::ListBuilder getFromPointer(_::PointerBuilder builder, const word* defaultValue) { | 520 inline static _::ListBuilder getFromPointer(_::PointerBuilder builder, const word* defaultValue) { |
| 518 return builder.getList(ElementSize::POINTER, defaultValue); | 521 return builder.getList(ElementSize::POINTER, defaultValue); |
| 519 } | 522 } |
| 520 inline static _::ListReader getFromPointer( | 523 inline static _::ListReader getFromPointer( |
