// using C++11 range-based for loop
GenomicIntervalQuery query(GenomicInterval("chr1:1000-2000"), dataset);
for (const BamRecord& record : query) {
    // ... do stuff ...
}

// OR

// using iterators directly
GenomicIntervalQuery query(GenomicInterval("chr1:1000-2000"), dataset);
auto iter = query.cbegin();
auto end  = query.cend();
for (; iter != end; ++iter) {
    // ... do stuff ...
}

