| 839 | } |
| 840 | |
| 841 | cmList::size_type cmList::ComputeIndex(index_type pos, bool boundCheck) const |
| 842 | { |
| 843 | if (boundCheck) { |
| 844 | if (this->Values.empty()) { |
| 845 | throw std::out_of_range( |
| 846 | cmStrCat("index: ", pos, " out of range (0, 0)")); |
| 847 | } |
| 848 | |
| 849 | auto index = pos; |
| 850 | if (!this->Values.empty()) { |
| 851 | auto length = this->Values.size(); |
| 852 | if (index < 0) { |
| 853 | index = static_cast<index_type>(length) + index; |
| 854 | } |
| 855 | if (index < 0 || length <= static_cast<size_type>(index)) { |
| 856 | throw std::out_of_range(cmStrCat("index: ", pos, " out of range (-", |
| 857 | this->Values.size(), ", ", |
| 858 | this->Values.size() - 1, ')')); |
| 859 | } |
| 860 | } |
| 861 | return index; |
| 862 | } |
| 863 | |
| 864 | return pos < 0 ? this->Values.size() + pos : pos; |
| 865 | } |
| 866 | cmList::size_type cmList::ComputeInsertIndex(index_type pos, |
| 867 | bool boundCheck) const |
| 868 | { |
no test coverage detected