Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:09:36

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/ArrayIO.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <ostream>
0010 #include <sstream>
0011 #include <string>
0012 
0013 #include "Array.hh"
0014 #include "SpanIO.hh"
0015 
0016 namespace celeritas
0017 {
0018 //---------------------------------------------------------------------------//
0019 /*!
0020  * Write the elements of array \a a to stream \a os.
0021  */
0022 template<class T, size_type N>
0023 std::ostream& operator<<(std::ostream& os, Array<T, N> const& a)
0024 {
0025     os << make_span(a);
0026     return os;
0027 }
0028 
0029 //---------------------------------------------------------------------------//
0030 /*!
0031  * Convert an array to a string representation for debugging.
0032  */
0033 template<class T, size_type N>
0034 std::string to_string(Array<T, N> const& a)
0035 {
0036     std::ostringstream os;
0037     os << a;
0038     return os.str();
0039 }
0040 
0041 //---------------------------------------------------------------------------//
0042 }  // namespace celeritas