This is an archive of the discontinued LLVM Phabricator instance.

Add ADL support to range based <algorithm> extensions
ClosedPublic

Authored by stephan.dollberg on Nov 14 2017, 12:01 AM.

Details

Summary

This adds support for ADL in the range based <algorithm> extensions
(llvm::for_each etc.).

Also adds the helper functions llvm::adl::begin and llvm::adl::end which wrap
std::begin and std::end with ADL support.

Saw this was missing from a recent llvm weekly post about adding llvm::for_each
and thought I might add it.

Diff Detail

Repository
rL LLVM

Event Timeline

dblaikie edited edge metadata.Nov 14 2017, 11:28 AM

I'd be inclined to call these llvm::adl_begin and llvm::adl_end (& perhaps we should have an llvm::adl_swap while we're at it? That being the canonical example of "always use with ADL" sort of library)? But don't mind too much.

Obviously either is fine by me be. Can switch from adl:: to adl_. You guys just have to let me know. Can also add adl_swap.

dblaikie accepted this revision.Nov 15 2017, 7:41 PM

Let's go with adl_begin/adl_end/adl_swap (feel free to add swap without further review following a similar pattern - though I guess maybe it doesn't need the helper indirection since it doesn't have a return value to worry about). Thanks!

This revision is now accepted and ready to land.Nov 15 2017, 7:41 PM

Switched to adl_ from adl::.

Also added adl_swap (adl guard is still needed for the noexcept specification).
Didn't migrate any std::swap usage yet.

This revision was automatically updated to reflect the committed changes.