| 85 | */ |
| 86 | template <typename Key> |
| 87 | static void bitstring(Key key, std::string &str) |
| 88 | { |
| 89 | Key mask = 0xFFFFFFFFFFFFFFFFull; |
| 90 | for (unsigned i = 0; i < size(key); i += 2 * 64) |
| 91 | { |
| 92 | const char digs[] = "0123456789ABCDEF"; |
| 93 | size_t count = 0; |
| 94 | for (unsigned j = 0; j < 2; j++) |
| 95 | { |
| 96 | uint64_t key64 = (key & mask).to_ullong(); |
| 97 | count += __builtin_popcountll(key64); |
| 98 | key >>= 64; |
| 99 | } |
| 100 | switch (count) |
| 101 | { |
| 102 | case 0: case 1: |
| 103 | break; |
| 104 | default: |
| 105 | count = 1 + (count - 2) / 9; break; |
| 106 | } |
| 107 | str += digs[count]; |
| 108 | } |
| 109 | } |
| 110 | template <> |
| 111 | void bitstring<Key128>(Key128 key, std::string &str) |
| 112 | { |
no test coverage detected