25 #include <unordered_set>
33 size_t appendMove(std::vector<T>& destination, std::vector<T>& source) {
36 }
else if (destination.empty()) {
37 destination = std::move(source);
38 return destination.size();
40 size_t const source_size = source.size();
41 destination.reserve(destination.size() + source_size);
42 std::move(std::begin(source), std::end(source), std::back_inserter(destination));
48 template <
typename... Ts,
typename T>
50 return (... || dynamic_cast<Ts const*>(ptr));
58 template <
typename CONTAINER>
63 template <
typename CONTAINER>
68 template <
typename CONTAINER>
70 template <
typename T,
typename A>
72 template <
typename T,
typename A>
74 template <
typename T,
typename A>
76 template <
typename T,
typename A>
78 template <
typename T,
typename A>
81 template <
typename OSTREAM,
typename CONTAINER>
82 OSTREAM& operator<<(OSTREAM& os, PrintContainer<CONTAINER> pc) {
83 if (pc.container.empty()) {
88 for (
auto& container : pc.container) {
92 for (
auto itr = pc.container.begin(); itr != pc.container.end(); ++itr) {
93 if constexpr (std::is_pointer_v<typename CONTAINER::value_type>) {
94 os << (itr == pc.container.begin() ?
'(' :
' ') << (
void const*)*itr;
96 os << (itr == pc.container.begin() ?
'(' :
' ') << *itr;
107 size_t formatDate(
char* buf,
size_t const max, int64_t
const unixtime);
115 int64_t
const timestamp,
116 int const dimension);
119 size_t formatHMS(
char* buf,
size_t const max, int64_t
const unixtime);
129 DivUMod div{num / den, num % den};
139 int64_t mod = num % den;
146 template <
typename T,
typename U>
147 inline bool contains(
const T& container,
const U& element) {
148 if (std::find(container.begin(), container.end(), element) == container.end()) {
157 #endif // SHARED_MISC_H
size_t appendMove(std::vector< T > &destination, std::vector< T > &source)
bool contains(const T &container, const U &element)
size_t formatDateTime(char *buf, size_t const max, int64_t const timestamp, int const dimension)
size_t formatHMS(char *buf, size_t const max, int64_t const unixtime)
size_t formatDate(char *buf, size_t const max, int64_t const unixtime)
uint64_t unsignedMod(int64_t num, int64_t den)
bool dynamic_castable_to_any(T const *ptr)
PrintContainer< CONTAINER > printContainer(CONTAINER &container)
DivUMod divUMod(int64_t num, int64_t den)