This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Fix template parameter names of llvm::{upper|lower}_bound
ClosedPublic

Authored by ilya-biryukov on Apr 10 2019, 6:30 AM.

Details

Summary

Rename template parameter for a search value from 'ForwardIt' to 'T'.
While here, also use perfect forwarding to pass the value to STL algos.

Event Timeline

ilya-biryukov created this revision.Apr 10 2019, 6:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 10 2019, 6:30 AM
  • clang-format
sammccall accepted this revision.Apr 10 2019, 8:20 AM
This revision is now accepted and ready to land.Apr 10 2019, 8:20 AM
This revision was automatically updated to reflect the committed changes.

Might've made sense to separate the NFC renaming from the perfect forwarding change (& the perfect forwarding change could potentially have some matching test coverage?)

Might've made sense to separate the NFC renaming from the perfect forwarding change (& the perfect forwarding change could potentially have some matching test coverage?)

I agree, sorry about mashing them in together. That said, I was confident this wouldn't cause any trouble in practice.
What kinds of tests are you thinking about? Checking that llvm::lower_bound works on non-copyable types?

Might've made sense to separate the NFC renaming from the perfect forwarding change (& the perfect forwarding change could potentially have some matching test coverage?)

I agree, sorry about mashing them in together. That said, I was confident this wouldn't cause any trouble in practice.
What kinds of tests are you thinking about? Checking that llvm::lower_bound works on non-copyable types?

Yeah, that'd probably suffice (if you were being extra super robust, and we generally aren't with these thin wrappers, I guess you could test that the parameter can be a temporary and a non-const value where the underlying type or passed in comparator takes by non-const ref (that would test that the forwarding works for things that must be passed by const ref and things that can't be passed by const ref and must be non-const ref))

Sure, happy to add some basic tests.
Unfortunately did not get to this today and I'm on vacation until next Tuesday. Will get back to this after I'm back.