This is an archive of the discontinued LLVM Phabricator instance.

[libc] Create cpp::IntegerSequence analogous to std::integer_sequence
ClosedPublic

Authored by abrachet on Feb 10 2022, 9:01 PM.

Diff Detail

Event Timeline

abrachet created this revision.Feb 10 2022, 9:01 PM
abrachet requested review of this revision.Feb 10 2022, 9:01 PM
lntue added inline comments.Feb 11 2022, 7:00 AM
libc/src/__support/CPP/Utility.h
22

Does it work with T that is not int? Doesn't append<> take template parameter of type T?

abrachet updated this revision to Diff 407899.Feb 11 2022, 8:55 AM

Add test with long, and static_assert that T is integral

abrachet marked an inline comment as done.Feb 11 2022, 8:55 AM
abrachet added inline comments.
libc/src/__support/CPP/Utility.h
22

Yes, added a test that it works with long

lntue accepted this revision.Feb 11 2022, 11:11 AM
This revision is now accepted and ready to land.Feb 11 2022, 11:11 AM
michaelrj added inline comments.Feb 11 2022, 11:38 AM
libc/test/utils/CPP/integer_sequence_test.cpp
17 ↗(On Diff #407899)

I would recommend changing long to long long since on some platforms (specifically Windows) a long is 32 bits. The C standard specifies that long long is at least 64 bits, and so it's more portable.

sivachandra accepted this revision.Feb 11 2022, 5:09 PM
sivachandra added inline comments.
libc/test/utils/CPP/integer_sequence_test.cpp
17 ↗(On Diff #407899)

Not clear how the size of the integer type matters.

abrachet updated this revision to Diff 408483.Feb 14 2022, 10:11 AM
abrachet marked an inline comment as done.
  • Rebase
  • Add test with unsigned type
This revision was landed with ongoing or failed builds.Feb 14 2022, 10:13 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 14 2022, 10:13 AM