|
||||
File indexing completed on 2025-01-18 09:54:46
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 2023-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/cont/EnumClassUtils.hh 0007 //! \brief Device-friendly utilities for mapping classes to variants 0008 //---------------------------------------------------------------------------// 0009 #pragma once 0010 0011 namespace celeritas 0012 { 0013 //---------------------------------------------------------------------------// 0014 /*! 0015 * Helper struct for mapping enums to classes. 0016 * 0017 * This class can be passed as a "tag" to functors that can then retrieve its 0018 * value or the associated class. It can be implicitly converted into a 0019 * SurfaceType enum for use in template parameters. 0020 */ 0021 template<class E, E EV, class T> 0022 struct EnumToClass 0023 { 0024 using enum_type = E; 0025 using type = T; 0026 0027 static constexpr enum_type value = EV; 0028 0029 CELER_CONSTEXPR_FUNCTION operator E() const noexcept { return value; } 0030 CELER_CONSTEXPR_FUNCTION enum_type operator()() const noexcept 0031 { 0032 return value; 0033 } 0034 }; 0035 0036 //---------------------------------------------------------------------------// 0037 } // 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 |