This is an archive of the discontinued LLVM Phabricator instance.

[NFC] Add size inference to to_vector
ClosedPublic

Authored by GMNGeoffrey on Nov 1 2021, 3:39 PM.

Details

Summary

A default calculated size for SmallVector was added in
https://reviews.llvm.org/D92522 after discussion in
https://groups.google.com/g/llvm-dev/c/Z-VwNCTRGSg, but to_vector still
requires an explicit size. This patch adds the default size to to_vector
as well, so that this case doesn't unnecessarily force users to pick an
arbitrary size.

Diff Detail

Event Timeline

GMNGeoffrey created this revision.Nov 1 2021, 3:39 PM
GMNGeoffrey requested review of this revision.Nov 1 2021, 3:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 1 2021, 3:39 PM

Please feel free to code golf this. I am a template metaprogramming noob.

silvas accepted this revision.Nov 1 2021, 4:27 PM
silvas added subscribers: rriddle, dblaikie.

This looks good to me. @rriddle @dexonsmith @dblaikie for thoughts.

Also, does this break any existing code? Or does overloading "just work" for the new defaulting case.

This revision is now accepted and ready to land.Nov 1 2021, 4:27 PM

Also, does this break any existing code? Or does overloading "just work" for the new defaulting case.

I'm pretty sure it "just works", but am waiting on pre-merge checks.

I suppose I should actually add a usage of the new default case :-D I'll go do that.

  • Add test for implicit to_vector size

Could do with a unit test in any case, but let's see about the implementation...

Yeah, I'm OK with it if it passes builds/bootstraps/bots/etc.

dblaikie accepted this revision.Nov 1 2021, 4:48 PM

Thanks!

This revision was automatically updated to reflect the committed changes.