Skip to content

Instantly share code, notes, and snippets.

View ZhekehZ's full-sized avatar
🌴
Chilling (no)

Eugene Kravchenko ZhekehZ

🌴
Chilling (no)
  • Saint Petersburg
View GitHub Profile
@ZhekehZ
ZhekehZ / source.cpp
Last active November 24, 2020 20:33
Нахождение преобразования облака точек
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <unordered_map>
#include <functional>
#include <ctime>
@ZhekehZ
ZhekehZ / nearest_points.cpp
Created April 5, 2020 15:11
Two-nearest-points-distance-search
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
using dist_2_t = uint64_t;
using point = std::pair<int, int>;
dist_2_t get_dist_2(const point &p1, const point &p2) {
dist_2_t dx = p1.first - p2.first;
@ZhekehZ
ZhekehZ / CmdTask.svg
Created April 6, 2020 22:52
ClassDiagram-Rougelike
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ZhekehZ
ZhekehZ / CMakeLists.txt
Created May 7, 2020 18:31
Split points into circles
cmake_minimum_required (VERSION 3.8)
project(split_into_circles)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -pedantic -DTEST")
add_executable(run_test split_into_circles.cpp)
@ZhekehZ
ZhekehZ / linear_types.hpp
Created August 28, 2020 14:15
C++ linear types by Ivan Cukic from Meeting C++ 2018 Secret Lightning talks
#include <type_traits>
#include <utility>
namespace detail {
template <typename T, typename U>
constexpr bool linear_usable_as_v =
std::is_nothrow_constructible_v<T, U> &&
std::is_nothrow_assignable_v<T&, U> &&
std::is_nothrow_convertible_v<U, T>;
@ZhekehZ
ZhekehZ / get_number_of_binders.hpp
Last active September 1, 2020 12:24
Returns the number of elements in the structure (type) that are applicable for structured binding declaration (https://en.cppreference.com/w/cpp/language/structured_binding). On godbolt: https://godbolt.org/z/Px3Pbb
#include <utility>
#include <tuple>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/control/if.hpp>
#define BINDERS_LIMIT 256 // Number of binders must be less than BINDERS_LIMIT
template <typename... Ts> struct overloads : Ts... { using Ts::operator()...; };
template <typename... Ts> overloads(Ts...) -> overloads<Ts...>;
@ZhekehZ
ZhekehZ / lambda_calculator.cpp
Last active August 29, 2022 18:50
Compile time lambda calculator in C++
#include <type_traits>
#include <tuple>
#include <iostream>
#include <string>
namespace lambda_term {
struct TermBase {};
template <typename T>
concept Term = std::is_base_of_v<TermBase, T>;
@ZhekehZ
ZhekehZ / compile_time_parser.hpp
Last active January 19, 2021 13:46
C++ compile time parser (without using constexpr strings) https://godbolt.org/z/8qxY3Y
#include <optional>
#include <utility>
#include <type_traits>
#include <tuple>
// C++ compile time parser (without using constexpr strings)
// PARSER DEFINITION
#define PARSER(...) template <__VA_ARGS__ __VA_OPT__(,) unsigned N, const char Str[N], unsigned Pos>
#include <iostream>
#include <type_traits>
#include <functional>
template <typename F, typename T>
struct case_impl : F {
using IS_CASE_IMPL_FOR = T;
using F::operator();
constexpr case_impl(F f) : F(f) {}
};