Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:46

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2022-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/data/detail/RefImpl.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "corecel/Types.hh"
0011 
0012 namespace celeritas
0013 {
0014 namespace detail
0015 {
0016 //---------------------------------------------------------------------------//
0017 //! Store a value/reference and dispatch function name based on MemSpace.
0018 
0019 template<class T, MemSpace M>
0020 struct RefGetter
0021 {
0022     T obj_;
0023 
0024     auto operator()() const -> decltype(auto) { return obj_.host_ref(); }
0025 };
0026 
0027 template<class T>
0028 struct RefGetter<T, MemSpace::device>
0029 {
0030     T obj_;
0031 
0032     auto operator()() const -> decltype(auto) { return obj_.device_ref(); }
0033 };
0034 
0035 //---------------------------------------------------------------------------//
0036 }  // namespace detail
0037 }  // namespace celeritas