Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:52:43

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/sys/detail/ActionRegistryImpl.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <type_traits>
0010 
0011 namespace celeritas
0012 {
0013 //---------------------------------------------------------------------------//
0014 class ActionInterface;
0015 
0016 namespace detail
0017 {
0018 //---------------------------------------------------------------------------//
0019 //! Traits class for differentiating const from mutable actions.
0020 template<class T, class = void>
0021 struct ActionSpTraits
0022 {
0023     static constexpr bool is_const_action = false;
0024     static constexpr bool is_mutable_action = false;
0025 };
0026 template<class T>
0027 struct ActionSpTraits<T, std::enable_if_t<std::is_base_of_v<ActionInterface, T>>>
0028 {
0029     static constexpr bool is_const_action = std::is_const_v<T>;
0030     static constexpr bool is_mutable_action = !is_const_action;
0031 };
0032 
0033 //---------------------------------------------------------------------------//
0034 //! True if T is a const class inheriting from ActionInterface.
0035 template<class T>
0036 inline constexpr bool is_const_action_v = ActionSpTraits<T>::is_const_action;
0037 
0038 //---------------------------------------------------------------------------//
0039 //! True if T is a mutable class inheriting from ActionInterface.
0040 template<class T>
0041 inline constexpr bool is_mutable_action_v
0042     = ActionSpTraits<T>::is_mutable_action;
0043 
0044 //---------------------------------------------------------------------------//
0045 }  // namespace detail
0046 }  // namespace celeritas