Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:02:04

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include <format>
0012 #include <sstream>
0013 #include <string_view>
0014 
0015 namespace Acts::detail {
0016 
0017 template <typename Char>
0018 struct BasicOstreamFormatter
0019     : std::formatter<std::basic_string_view<Char>, Char> {
0020   template <typename T, typename OutputIt>
0021   auto format(const T& value, std::basic_format_context<OutputIt, Char>& ctx)
0022       const -> OutputIt {
0023     std::basic_stringstream<Char> ss;
0024     ss << value;
0025     return std::formatter<std::basic_string_view<Char>, Char>::format(ss.view(),
0026                                                                       ctx);
0027   }
0028 };
0029 
0030 using OstreamFormatter = BasicOstreamFormatter<char>;
0031 
0032 }  // namespace Acts::detail
0033 
0034 #define ACTS_OSTREAM_FORMATTER(type) \
0035   template <>                        \
0036   struct std::formatter<type> : Acts::detail::OstreamFormatter {}