Skip to content

Commit

Permalink
Further cleaned up imagesOverlap
Browse files Browse the repository at this point in the history
  • Loading branch information
r-owen committed May 11, 2018
1 parent 23141bd commit bda3f5e
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/image/Image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -699,17 +699,6 @@ geom::Box2I bboxFromMetadata(daf::base::PropertySet & metadata)
return geom::Box2I(xy0, dims);
}

namespace {

template <typename PtrLess = std::less<void const* const>>
bool ptrsOverlap(void const* const beg1Addr, void const* const end1Addr, void const* const beg2Addr,
void const* const end2Addr, PtrLess ptrLess = PtrLess()) {
// std::less is safer than < for generic pointers
return ptrLess(beg1Addr, end2Addr) && ptrLess(beg2Addr, end1Addr);
}

} // namespace

template <typename T1, typename T2>
bool imagesOverlap(ImageBase<T1> const& image1, ImageBase<T2> const& image2) {
auto arr1 = image1.getArray();
Expand All @@ -722,7 +711,8 @@ bool imagesOverlap(ImageBase<T1> const& image1, ImageBase<T2> const& image2) {
auto beg2Addr = arr2.front().begin();
auto end2Addr = arr2.back().end();

return ptrsOverlap(beg1Addr, end1Addr, beg2Addr, end2Addr);
auto ptrLess = std::less<void const* const>();
return ptrLess(beg1Addr, end2Addr) && ptrLess(beg2Addr, end1Addr);
}

//
Expand Down

0 comments on commit bda3f5e

Please sign in to comment.