Skip to content

Instantly share code, notes, and snippets.

@eao197
eao197 / try_get_cpu_set_info.cpp
Created April 11, 2025 04:52
Эксперимент получения информации об CPU Set в Windows 10/11
#define NOMINMAX
#include <windows.h>
#include <iostream>
#include <stdexcept>
#include <vector>
#include <print>
#include <format>
void
@eao197
eao197 / upcastable_root_and_node_20240724_002.cpp
Created July 24, 2024 12:57
A dirty sketch of using root_t<T> and node_t<D, B> to traverse type hierarchy with respect to message mutability
#include <iostream>
#include <typeindex>
#include <stdexcept>
enum class message_mutability_t
{
immutable_message,
mutable_message
};
@eao197
eao197 / upcastable_root_and_node_20240724.cpp
Created July 24, 2024 04:56
A dirty sketch of using root_t<T> and node_t<D, B> to traverse type hierarchy down up
#include <iostream>
#include <typeindex>
#include <stdexcept>
class message_upcaster_t;
using upcaster_factory_t = message_upcaster_t (*)() noexcept;
class message_upcaster_t
{
std::type_index m_self_type;
@eao197
eao197 / utf8_checker_speed.cpp
Created June 19, 2024 13:23
Простая программа для сравнения нескольких реализаций utf8_checker/decoder.
#include <algorithm>
#include <array>
#include <chrono>
#include <iostream>
#include <span>
#include <string>
#include <string_view>
#include <cstdint>
namespace restinio
@eao197
eao197 / approach1.cpp
Created April 26, 2024 13:08
Возможные реализации thread_pool-ов для задачи рекурсивного обхода подкаталогов
#include <condition_variable>
#include <functional>
#include <iostream>
#include <mutex>
#include <queue>
#include <thread>
#include <vector>
namespace demo
{
@eao197
eao197 / gist:2b48c0adcaa0030b539f982759d1ba38
Created April 12, 2024 04:19
Заметки для лекции про стандартные контейнеры C++
/***
https://en.cppreference.com/w/cpp/container
*/
/***
Задача стандартной библиотеки -- быть стандартной библиотекой.
@eao197
eao197 / std_multithreading_basics.cpp
Last active April 12, 2024 13:42
Примеры для лекции про базовые средства поддержки многопоточности в C++
/***
Класс std::thread
*/
#include <iostream>
#include <thread>
void SayHello()
@eao197
eao197 / templates_part2.cpp
Last active April 10, 2024 10:03
Примеры для второй части лекции про шаблоны C++
/***
SFINAE: Substitution failure is not an error
*/
// В основном базируется на std::enable_if
// https://en.cppreference.com/w/cpp/types/enable_if
#include <type_traits>
@eao197
eao197 / templates_part1.cpp
Last active April 10, 2024 07:55
Примеры для первой части лекции про шаблоны C++
/***
Реализация шаблона должна быть доступна компилятору.
Поэтому шаблоны размещают в .hpp-файлах
*/
/////////////////////////////////////////////////////
/***
@eao197
eao197 / custom_data_source_message.cpp
Created March 12, 2024 12:17
An example of sending so_5::stats::messages::quantity<int> via custom data-source
#include <so_5/all.hpp>
namespace example
{
class a_stats_listener_t final : public so_5::agent_t
{
public :
a_stats_listener_t( context_t ctx )
: so_5::agent_t( std::move(ctx) )