lxgui
Loading...
Searching...
No Matches
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
11namespace lxgui::utils {
12
13template<typename C, typename T>
14auto find(C& v, const T& s) {
15 return std::find(v.begin(), v.end(), s);
16}
17
18template<typename C, typename T>
19auto 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
25namespace std {
26
27template<class T, std::size_t N>
28ostream& 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
40template<class T>
41ostream& 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
auto find(C &v, const T &s)
Definition utils_std.hpp:14
auto find_if(C &v, T &&f)
Definition utils_std.hpp:19
STL namespace.
ostream & operator<<(ostream &o, const array< T, N > &a)
Definition utils_std.hpp:28