|
||||
File indexing completed on 2025-01-30 10:03:44
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 2024 UT-Battelle, LLC, and other Celeritas developers. 0003 // See the top-level COPYRIGHT file for details. 0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0005 //---------------------------------------------------------------------------// 0006 //! \file corecel/math/UnitUtils.hh 0007 //! \brief Helpers for unit trait classes 0008 //---------------------------------------------------------------------------// 0009 #pragma once 0010 0011 #include "corecel/Macros.hh" 0012 0013 namespace celeritas 0014 { 0015 //---------------------------------------------------------------------------// 0016 //! Value is 1 / C1::value() 0017 template<class C1> 0018 struct UnitInverse 0019 { 0020 //! Get the conversion factor of the resulting unit 0021 static CELER_CONSTEXPR_FUNCTION auto value() noexcept -> decltype(auto) 0022 { 0023 return 1 / C1::value(); 0024 } 0025 }; 0026 0027 //---------------------------------------------------------------------------// 0028 //! Value is C1::value() / C2::value() 0029 template<class C1, class C2> 0030 struct UnitDivide 0031 { 0032 //! Get the conversion factor of the resulting unit 0033 static CELER_CONSTEXPR_FUNCTION auto value() noexcept -> decltype(auto) 0034 { 0035 return C1::value() / C2::value(); 0036 } 0037 }; 0038 0039 //! Value is C1::value() * C2::value() 0040 template<class C1, class C2> 0041 struct UnitProduct 0042 { 0043 //! Get the conversion factor of the resulting unit 0044 static CELER_CONSTEXPR_FUNCTION auto value() noexcept -> decltype(auto) 0045 { 0046 return C1::value() * C2::value(); 0047 } 0048 }; 0049 0050 //---------------------------------------------------------------------------// 0051 } // namespace celeritas
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |