FairMQ  1.2.1
C++ Message Passing 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 <initializer_list>
13 #include <sstream>
14 #include <string>
15 #include <vector>
16 
17 namespace fair
18 {
19 namespace mq
20 {
21 namespace tools
22 {
23 
27 template<typename ... T>
28 auto ToString(T&&... t) -> std::string
29 {
30  std::stringstream ss;
31  (void)std::initializer_list<int>{(ss << t, 0)...};
32  return ss.str();
33 }
34 
36 inline auto ToStrVector(const int argc, char* const argv[], const bool dropProgramName = true) -> std::vector<std::string>
37 {
38  auto res = std::vector<std::string>{};
39  if (dropProgramName)
40  {
41  res.assign(argv + 1, argv + argc);
42  } else
43  {
44  res.assign(argv, argv + argc);
45  }
46  return res;
47 }
48 
49 } /* namespace tools */
50 } /* namespace mq */
51 } /* namespace fair */
52 
53 #endif /* FAIR_MQ_TOOLS_STRINGS_H */
Definition: DeviceRunner.h:23