blob: c21a7bbde33e864ffae0ca16b4c20d6f4803f5b6 (
plain)
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
|
#pragma once
#include <iostream>
#include "defs.h"
using namespace std;
template <typename T>
constexpr static T clearLowestBit(T value) {
return value & (value - 1);
}
template <typename T>
constexpr static bool ispow2(T value) {
return clearLowestBit(value) == 0;
}
template <typename T>
constexpr static T ceil2(T value) {
T value2 = clearLowestBit(value);
if (value2 == 0) return value;
while (true) {
value = value2;
value2 = clearLowestBit(value);
if (value2 == 0) return value << 1;
}
}
ostream& operator<<(ostream &os, const Poly &p);
|