-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.h
33 lines (25 loc) · 826 Bytes
/
common.h
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
#pragma once
#include <rang.hpp>
#include <cmath>
//#include <map>
//#include <string>
typedef double Float;
[[ noreturn ]] void unreachable();
#define warning(msg...) {std::cerr << rang::fg::yellow << "warning: " << rang::style::reset << msg << std::endl;}
inline bool isFloatEqual(Float f1, Float f2) {
return fabs(f1 - f2) < 0.001;
}
//template<typename K, typename V>
//inline std::map<K,V> operator+(const std::map<K,V> &m1, const std::map<K,V> &m2) {
// auto m = m1;
// for (auto i : m2)
// m[i.first] = i.second;
// return m;
//}
template<template<typename _K, typename _V, class _C, class _A> class Map, typename K, typename V, class C, class A>
inline Map<K,V,C,A> operator+(const Map<K,V,C,A> &m1, const Map<K,V,C,A> &m2) {
auto m = m1;
for (auto i : m2)
m[i.first] = i.second;
return m;
}