|
|
|||
File indexing completed on 2026-10-26 09:34:35
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/math/detail/SpanUtilsImpl.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <cstddef> 0010 0011 #include "corecel/Macros.hh" 0012 #include "corecel/cont/Array.hh" 0013 #include "corecel/cont/Span.hh" 0014 0015 namespace celeritas 0016 { 0017 namespace detail 0018 { 0019 //---------------------------------------------------------------------------// 0020 //! Load a const span into a fixed-size array. 0021 template<class T, std::size_t N> 0022 CELER_FUNCTION Array<T, N> load_array(Span<T const, N> s) 0023 { 0024 static_assert(N != dynamic_extent); 0025 Array<T, N> result; 0026 for (std::size_t i = 0; i != N; ++i) 0027 result[i] = s[i]; 0028 return result; 0029 } 0030 0031 //---------------------------------------------------------------------------// 0032 //! Store a fixed-size array into a span. 0033 template<class T, std::size_t N> 0034 CELER_FUNCTION void store_array(Array<T, N> const& a, Span<T, N> dst) 0035 { 0036 static_assert(N != dynamic_extent); 0037 for (std::size_t i = 0; i != N; ++i) 0038 dst[i] = a[i]; 0039 } 0040 0041 //---------------------------------------------------------------------------// 0042 } // namespace detail 0043 } // 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 |
|