Change as_words() to return fixed-size std::span#364
Conversation
There was a problem hiding this comment.
Pull request overview
This PR modernizes the as_words() API by changing it from returning raw pointers to returning fixed-size std::span objects, providing better type safety and compile-time size information.
Changes:
- Modified
as_words()template functions to returnstd::span<uint64_t, N>andstd::span<const uint64_t, N>instead of raw pointers - Removed specialized
uint128overloads (now covered by the template) - Updated all call sites to use
.data()where raw pointers are needed - Modernized test code to use
std::ranges::generatewith span's.subspan()method - Changed parameter type from
inttosize_tfor better type safety
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| include/intx/intx.hpp | Updated as_words() template functions to return fixed-size spans; removed redundant uint128 specializations; updated all usages to call .data() when raw pointers are needed |
| test/utils/random.cpp | Added as_words() overload for uint64_t& returning std::span<uint64_t, 1>; modernized random generation to use std::ranges::generate with .subspan(); changed parameter type from int to size_t |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #364 +/- ##
==========================================
- Coverage 98.71% 98.71% -0.01%
==========================================
Files 15 15
Lines 1867 1863 -4
==========================================
- Hits 1843 1839 -4
Misses 24 24
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|



No description provided.