Skip to content

Instantly share code, notes, and snippets.

View slyshykO's full-sized avatar
🇺🇦
🇺🇦

Oleksiy Slyshyk slyshykO

🇺🇦
🇺🇦
  • Ukraine, Kyiv
View GitHub Profile
@slyshykO
slyshykO / raii_malloc.cpp
Created April 30, 2018 13:14
RAII malloc
#include <memory>
int main()
{
auto Data =
std::unique_ptr<double, decltype(free)*>{
reinterpret_cast<double*>(malloc(sizeof(double)*50)),
free };
return 0;
}
@slyshykO
slyshykO / snprintf.cpp
Last active March 14, 2018 17:44
snprintf with zero ending
template <uint32_t N, typename... Args>
void _snprintf(char (&buf)[N], const char* format, Args&&... args)
{
snprintf(buf, N, format, args...);
buf[N-1] = '\0';
};
@slyshykO
slyshykO / FastFunc.hpp
Created February 20, 2018 12:44 — forked from vittorioromeo/FastFunc.hpp
Don Clugston's fast delegate C++11 implementation
#ifndef SSVU_FASTFUNC
#define SSVU_FASTFUNC
#include <cstring>
#include <type_traits>
#include <cassert>
#include <cstddef>
#include <memory>
#include <new>
#include <utility>