FairMQ  1.4.33
C++ Message Queuing Library and Framework
Strings.h
1 /********************************************************************************
2  * Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #ifndef FAIR_MQ_TOOLS_STRINGS_H
10 #define FAIR_MQ_TOOLS_STRINGS_H
11 
12 #include <array>
13 #include <initializer_list>
14 #include <sstream>
15 #include <string>
16 #include <vector>
17 
18 namespace fair::mq::tools
19 {
20 
24 template<typename ... T>
25 auto ToString(T&&... t) -> std::string
26 {
27  std::stringstream ss;
28  (void)std::initializer_list<int>{(ss << t, 0)...};
29  return ss.str();
30 }
31 
33 inline auto ToStrVector(const int argc, char*const* argv, const bool dropProgramName = true) -> std::vector<std::string>
34 {
35  if (dropProgramName) {
36  return std::vector<std::string>(argv + 1, argv + argc);
37  } else {
38  return std::vector<std::string>(argv, argv + argc);
39  }
40 }
41 
42 } // namespace fair::mq::tools
43 
44 #endif /* FAIR_MQ_TOOLS_STRINGS_H */

privacy