![]() |
|
|||
File indexing completed on 2025-09-15 08:55:03
0001 //------------------------------- -*- C++ -*- -------------------------------// 0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details 0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0004 //---------------------------------------------------------------------------// 0005 //! \file corecel/cont/EnumClassUtils.hh 0006 //! \brief Device-friendly utilities for mapping classes to variants 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 namespace celeritas 0011 { 0012 //---------------------------------------------------------------------------// 0013 /*! 0014 * Helper struct for mapping enums to classes. 0015 * 0016 * This class can be passed as a "tag" to functors that can then retrieve its 0017 * value or the associated class. It can be implicitly converted into a 0018 * SurfaceType enum for use in template parameters. 0019 */ 0020 template<class E, E EV, class T> 0021 struct EnumToClass 0022 { 0023 using enum_type = E; 0024 using type = T; 0025 0026 static constexpr enum_type value = EV; 0027 0028 CELER_CONSTEXPR_FUNCTION operator E() const noexcept { return value; } 0029 CELER_CONSTEXPR_FUNCTION enum_type operator()() const noexcept 0030 { 0031 return value; 0032 } 0033 }; 0034 0035 //---------------------------------------------------------------------------// 0036 } // 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 |
![]() ![]() |