Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:55:03

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/SpanIO.json.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <nlohmann/json.hpp>
0010 
0011 #include "Span.hh"
0012 
0013 namespace celeritas
0014 {
0015 //---------------------------------------------------------------------------//
0016 /*!
0017  * Write a span to a JSON file.
0018  */
0019 template<class T, std::size_t N>
0020 void to_json(nlohmann::json& j, Span<T, N> const& value)
0021 {
0022     j = nlohmann::json::array();
0023     for (std::size_t i = 0; i != value.size(); ++i)
0024     {
0025         j.push_back(value[i]);
0026     }
0027 }
0028 
0029 //---------------------------------------------------------------------------//
0030 }  // namespace celeritas