xfmt1.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <algorithm>
4 #include <forward_list>
5 #include <functional>
6 #include <ostream>
7 
8 namespace nmx {
9 
10 template<typename T>
11 class Fmt
12 {
13 private:
14  std::forward_list<const T *> _items;
15  const std::string _sep = ",", _lend = "\n";
16 
17 public:
18  Fmt() {}
19 
20  template<class... Y>
21  Fmt(const Y &... y)
22  : _items{ &y... } {}
23 
24  friend std::ostream &operator<<(std::ostream &os, Fmt<T> fmt) {
25  for (const auto *p : fmt._items) {
26  p->save(os);
27  }
28  return os;
29  }
30 };
31 
32 } // namespace nmx
Definition: xfmt1.h:11
Fmt()
Definition: xfmt1.h:18
Fmt(const Y &... y)
Definition: xfmt1.h:21