Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-13 08:53:53

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/QuantityIO.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <ostream>
0010 
0011 #include "Quantity.hh"
0012 
0013 namespace celeritas
0014 {
0015 //---------------------------------------------------------------------------//
0016 /*!
0017  * Output an quantity with its label.
0018  */
0019 template<class UnitT, class ValueT>
0020 std::ostream& operator<<(std::ostream& os, Quantity<UnitT, ValueT> const& q)
0021 {
0022     static_assert(sizeof(UnitT::label()) > 0,
0023                   "Unit does not have a 'label' definition");
0024     os << q.value() << " [" << UnitT::label() << ']';
0025     return os;
0026 }
0027 
0028 //---------------------------------------------------------------------------//
0029 }  // namespace celeritas