Skip to content

Instantly share code, notes, and snippets.

hhggit hhggit

Block or report user

Report or block hhggit

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View extend_helper.hpp
// Copyright 2019 hhggit.
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
hhggit / cache.hpp
Created Jul 5, 2018
a thread-safe cache using boost::upgrade_lock
View cache.hpp
#include <boost/thread/shared_mutex.hpp>
#include <boost/thread/condition_variable.hpp>
template <typename T>
class cache {
cache(T t) : data_(std::move(t)) {}
template <typename F, typename F1>
void fetch_update(F&& fetch, F1&& update) {
View fmt_as_bytes.hpp
* usage: fmt_as_bytes(format_str, [params to bound the bytes]...)
* examples:
std::vector<uint16_t> v{0xFFc8, 0x301, 0x504};
fmt::format("{}", fmt_as_bytes{"{:03x},", v})); // "0c8,0ff,001,003,004,005,"
uint32_t a[] = {0xFFc8, 0x301, 0x504, 0xab2, 0x3};
fmt::format("HEX:{}", fmt_as_bytes{" {:02X}", a+1, 3})); // "HEX: 01 03 00 00 04 05 00 00 B2 0A 00 00"
You can’t perform that action at this time.