lxgui
utils_std.hpp
1 #ifndef LXGUI_UTILS_STD_HPP
2 #define LXGUI_UTILS_STD_HPP
3 
4 #include "lxgui/lxgui.hpp"
5 
6 #include <algorithm>
7 #include <array>
8 #include <iostream>
9 #include <vector>
10 
11 namespace lxgui::utils {
12 
13 template<typename C, typename T>
14 auto find(C& v, const T& s) {
15  return std::find(v.begin(), v.end(), s);
16 }
17 
18 template<typename C, typename T>
19 auto find_if(C& v, T&& f) {
20  return std::find_if(v.begin(), v.end(), std::forward<T>(f));
21 }
22 
23 } // namespace lxgui::utils
24 
25 namespace std {
26 
27 template<class T, std::size_t N>
28 ostream& operator<<(ostream& o, const array<T, N>& a) {
29  o << "(";
30  for (std::size_t i = 0; i < N; ++i) {
31  if (i != N - 1)
32  o << a[i] << ", ";
33  else
34  o << a[i];
35  }
36  o << ")";
37  return o;
38 }
39 
40 template<class T>
41 ostream& operator<<(ostream& o, const vector<T>& a) {
42  o << "(";
43  const std::size_t n = a.size();
44  for (std::size_t i = 0; i < n; ++i) {
45  if (i != n - 1)
46  o << a[i] << ", ";
47  else
48  o << a[i];
49  }
50  o << ")";
51  return o;
52 }
53 
54 } // namespace std
55 
56 #endif
std::ostream & operator<<(std::ostream &stream, const color &c)
Definition: gui_color.cpp:212
auto find(C &v, const T &s)
Definition: utils_std.hpp:14
auto find_if(C &v, T &&f)
Definition: utils_std.hpp:19