Skip to content

Use User-defined literals#2235

Open
esseivaju wants to merge 7 commits intoceleritas-project:developfrom
esseivaju:use-udl
Open

Use User-defined literals#2235
esseivaju wants to merge 7 commits intoceleritas-project:developfrom
esseivaju:use-udl

Conversation

@esseivaju
Copy link
Member

Use User-defined literals instead of units multiplication. This update straight-forward cases only.

Credits to Copilot.

@esseivaju esseivaju requested a review from sethrj February 5, 2026 23:30
@esseivaju esseivaju added core Software engineering infrastructure (corecel) minor Refactoring or minor internal changes/fixes labels Feb 5, 2026
@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.83%. Comparing base (43e05ae) to head (3aefebf).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2235      +/-   ##
===========================================
+ Coverage    86.81%   86.83%   +0.01%     
===========================================
  Files         1330     1330              
  Lines        42019    42020       +1     
  Branches     12950    12950              
===========================================
+ Hits         36480    36486       +6     
+ Misses        4335     4332       -3     
+ Partials      1204     1202       -2     
Files with missing lines Coverage Δ
src/celeritas/Units.hh 100.00% <ø> (ø)
...c/celeritas/em/distribution/WentzelDistribution.hh 98.36% <ø> (ø)
...celeritas/em/msc/detail/UrbanMscSafetyStepLimit.hh 98.57% <100.00%> (ø)
src/celeritas/em/msc/detail/UrbanMscScatter.hh 92.89% <ø> (ø)
src/celeritas/ext/detail/NaviTouchableUpdater.hh 100.00% <100.00%> (ø)
src/celeritas/phys/PhysicsOptions.hh 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Test summary

 5 893 files   9 431 suites   18m 31s ⏱️
 2 146 tests  2 118 ✅  28 💤 0 ❌
32 254 runs  32 096 ✅ 158 💤 0 ❌

Results for commit 3aefebf.

♻️ This comment has been updated with latest results.

Copy link
Member

@sethrj sethrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's work needs some checking 🙃

{
return native_value_to<units::MevMomentum>(2 * units::femtometer
/ constants::hbar_planck)
using celeritas::units::literals::operator""_fm;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This construction is pretty awkward... what about using namespace celeritas::units::literals? That seems to be the standard paradigm for literals.

CELER_CONSTEXPR_FUNCTION Constant operator""_##NAME( \
unsigned long long int v) \
{ \
return v * units::NAME; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's gone crazy

Copy link
Member Author

@esseivaju esseivaju Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to return double (or long double if we care about it?) which matches the Constant interface returning the literal type, and not real_type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Software engineering infrastructure (corecel) minor Refactoring or minor internal changes/fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants