IteratorType end_;
};
+// Returns a (begin, end) iterator pair for the given container.
+template <typename ValueType,
+ class IteratorType = UptrVectorIterator<ValueType>>
+inline IteratorRange<IteratorType> make_range(
+ std::vector<std::unique_ptr<ValueType>>& container) {
+ return {IteratorType(&container, container.begin()),
+ IteratorType(&container, container.end())};
+}
+
+// Returns a const (begin, end) iterator pair for the given container.
+template <typename ValueType,
+ class IteratorType = UptrVectorIterator<ValueType, true>>
+inline IteratorRange<IteratorType> make_const_range(
+ const std::vector<std::unique_ptr<ValueType>>& container) {
+ return {IteratorType(&container, container.cbegin()),
+ IteratorType(&container, container.cend())};
+}
+
template <typename VT, bool IC>
inline UptrVectorIterator<VT, IC>& UptrVectorIterator<VT, IC>::operator++() {
++iterator_;
}
inline IteratorRange<Module::inst_iterator> Module::debugs() {
- return IteratorRange<inst_iterator>(inst_iterator(&debugs_, debugs_.begin()),
- inst_iterator(&debugs_, debugs_.end()));
+ return make_range(debugs_);
}
inline IteratorRange<Module::const_inst_iterator> Module::debugs() const {
- return IteratorRange<const_inst_iterator>(
- const_inst_iterator(&debugs_, debugs_.cbegin()),
- const_inst_iterator(&debugs_, debugs_.cend()));
+ return make_const_range(debugs_);
}
inline IteratorRange<Module::inst_iterator> Module::annotations() {
- return IteratorRange<inst_iterator>(
- inst_iterator(&annotations_, annotations_.begin()),
- inst_iterator(&annotations_, annotations_.end()));
+ return make_range(annotations_);
}
inline IteratorRange<Module::const_inst_iterator> Module::annotations() const {
- return IteratorRange<const_inst_iterator>(
- const_inst_iterator(&annotations_, annotations_.cbegin()),
- const_inst_iterator(&annotations_, annotations_.cend()));
+ return make_const_range(annotations_);
}
inline Module::const_iterator Module::cbegin() const {