Back to home page

EIC code displayed by LXR

 
 

    


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

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