File size: 844 Bytes
d1be154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef OT_UTILITY_UTILITY_HPP_
#define OT_UTILITY_UTILITY_HPP_

#include <ot/utility/lambda.hpp>
#include <ot/utility/logger.hpp>
#include <ot/utility/tokenizer.hpp>
#include <ot/utility/index.hpp>
#include <ot/utility/os.hpp>
#include <ot/utility/CLI11.hpp>

// Miscellaneous
namespace ot {

// Concatnate a string
template <typename... Ts>
std::string to_string(Ts&&... ts) {
  std::ostringstream oss;
  (oss << ... << ts);
  return oss.str();
}

// Resize a container to fit a given size
template <typename T>
void resize_to_fit(size_t N, T& v) {
  auto sz = v.size();
  for(; sz < N; sz = (sz==0) ? 32 : (sz << 1));
  v.resize(sz);
}

// Resize containers to fit a given size
template <typename... T, std::enable_if_t<(sizeof...(T)>1), void>* = nullptr>
void resize_to_fit(size_t N, T&...vs) {
  (resize_to_fit(N, vs), ...);
}

};

#endif