Skip to content

Instantly share code, notes, and snippets.

View floor_ceil_power_2.cpp
inline constexpr uint32_t ceilPowerOfTwo(uint32_t num) {
num |= (num >> 1);
num |= (num >> 2);
num |= (num >> 4);
num |= (num >> 8);
num |= (num >> 16);
return num - (num >> 1);
}
inline constexpr uint32_t roundupPowerOfTwo(uint32_t num) {
View template selector.cpp
class connbase {
public:
virtual void Send() = 0;
};
typedef enum {
WithEnc,
WithoutEnc
}enc;
@lvpidadiao
lvpidadiao / bytes_buf.cpp
Created Oct 15, 2019
simple bytes buf。with extend and noextend buffer, also the buffer could managed by yourself。
View bytes_buf.cpp
//
// Created by TrevorProfessor on 2019-09-18.
//
#include <cstring>
#include "bytes_buf.hpp"
static int align128(int v) {
#define CACHE_LINE_SIZE 128