We still have that one convenience accessor to avoid the awkward double bracket issue: shape.dims()[i].
| 345 | // We still have that one convenience accessor to avoid |
| 346 | // the awkward double bracket issue: shape.dims()[i]. |
| 347 | int dims(int i) const { |
| 348 | // Always check for out-of-bounds accesses, even in optimized builds where |
| 349 | // standard assertions are disabled. Out-of-bounds access here is a common |
| 350 | // occurrence. |
| 351 | CHECK_GE(i, 0); |
| 352 | CHECK_GT(dims_.size(), i); |
| 353 | return dims_[i]; |
| 354 | } |
| 355 | |
| 356 | bool operator==(const Shape& comp) const { |
| 357 | return (this->dims_ == comp.dims()); |