https://mooseframework.inl.gov
StreamArguments.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include <tuple>
13 
14 /***
15  * Streams all of the given arguments into the given stream
16  */
17 template <class StreamType>
18 void
19 streamArguments(StreamType &)
20 {
21 }
22 
23 // Recursive parameter pack expansion
24 template <class StreamType, typename T, typename... Args>
25 void
26 streamArguments(StreamType & ss, T && val, Args &&... args)
27 {
28  ss << val;
29  streamArguments(ss, std::forward<Args>(args)...);
30 }
31 
32 // Base case for Tuple expansion recursive method
33 template <std::size_t I = 0, class StreamType, typename... Args>
34 inline typename std::enable_if<I == sizeof...(Args), void>::type
35 streamArguments(StreamType & /*ss*/, std::tuple<Args...> /*args*/)
36 {
37 }
38 
39 // Recursive method for tuple expansion
40 // clang-format off
41 template <std::size_t I = 0, class StreamType, typename... Args>
42 inline typename std::enable_if<I < sizeof...(Args), void>::type
43 streamArguments(StreamType & ss, std::tuple<Args...> args)
44 {
45  ss << std::get<I>(args);
46  streamArguments<I + 1, StreamType, Args...>(ss, args);
47 }
48 // clang-format on
void streamArguments(StreamType &)