Skip to content

Instantly share code, notes, and snippets.

View qrealka's full-sized avatar

Dmitry Loginov qrealka

View GitHub Profile
@qrealka
qrealka / main.cpp
Created August 3, 2018 12:39 — forked from elliotchance/main.cpp
Easily customise how verbose googletest is with unit test results.
#include "gtest/gtest.h"
using namespace testing;
class ConfigurableEventListener : public TestEventListener
{
protected:
TestEventListener* eventListener;
@qrealka
qrealka / path_contracts.h
Created August 20, 2018 17:29
aspathname proto
#ifndef PATH_CONTRACTS_H_2018_08_20_17_14_18_238_H
#define PATH_CONTRACTS_H_2018_08_20_17_14_18_238_H
#include <memory>
#include <type_traits>
#include <utility>
#include <filesystem>
namespace nitro {
namespace file_system {
@qrealka
qrealka / gil_render.h
Created August 21, 2018 13:36
Boost GIL render for agg
/*=============================================================================
Copyright (c) 2006 Joel de Guzman
gil_renderer: an AGG renderer using GIL
Use, modification and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef AGG_GIL_RENDERER_INCLUDED
@qrealka
qrealka / function_ref.h
Created August 24, 2018 13:25
foonathan function_vref
// https://www.reddit.com/r/cpp/comments/5p3mob/implementing_function_view_is_harder_than_you/
#include <type_traits>
#include <utility>
//=== function_ref ===//
namespace detail
{
template <typename Returned, typename Required>
struct compatible_return_type
: std::integral_constant<bool, std::is_void<Required>::value
@qrealka
qrealka / forwarder.cpp
Created August 27, 2018 14:57
call forwarder
#include <functional>
#include <type_traits>
#include <memory>
#include <thread>
#include <atomic>
#include <mutex>
#include <condition_variable>
#include <future>
#define ENABLE_IF(...) \
@qrealka
qrealka / ui_events.cpp
Last active August 28, 2018 11:40
testing prototype for mesage-only window
struct hidden_window {
hidden_window(HINSTANCE instance, WPARAM message_id = WM_USER + 1000)
: wnd{::CreateWindowW(L"STATIC", L"", 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr, instance, nullptr)}
, msg_id{message_id}
{
::SetWindowLongPtrW(wnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(procedure));
}
static LRESULT procedure(HWND handle, UINT message, WPARAM wParam, LPARAM lParam)
{
@qrealka
qrealka / boost_factory.cpp
Last active August 31, 2018 11:33
factory for IoC
// TODO: replace to std::function + std::bind
template< class AbstractClass,class IdType = size_t, class MakeType = boost::function< typename std::remove_pointer<AbstractClass>::type*()> >
class Factory
{
using abstract_type = typename std::remove_pointer<AbstractClass>::type;
boost::container::flat_map<IdType,MakeType> factory_map;
public:
void register_factory(IdType type_id,const MakeType& make)
{
factory_map.insert(std::make_pair(type_id,make));
@qrealka
qrealka / as_literal_const.cpp
Last active September 11, 2018 11:42
literal const
#ifndef AS_LITERAL_CONST_H_2018_08_24_13_51_51_019_H
#define AS_LITERAL_CONST_H_2018_08_24_13_51_51_019_H
#include <boost/utility/string_ref.hpp>
#include <boost/assert.hpp>
// based on this discussion
// https://groups.google.com/forum/#!msg/boost-developers-archive/dg7Ma2gK3zk/JZW4Jt-AAioJ
// BOOST will never provide this feature, following reason:
// const char s[] = {'0', '1', '2', '\0', '\1'}; // User knows that this has fixed size
@qrealka
qrealka / concepts.h
Last active September 11, 2018 11:40
conditional_variable wrapper
#ifndef 2018_08_29_11_35_23_277_H
#define 2018_08_29_11_35_23_277_H
#include <boost/config.hpp>
#include <boost/concept_check.hpp>
#include <type_traits>
namespace test {
// for compile-time checks
namespace concepts {
@qrealka
qrealka / remote_proto.cpp
Created September 11, 2018 15:59
prototype feedback
// library wrapper aroung http functions (WinInet, curl etc)
class http_backend;
// could be expanded/updated
enum class object_type {
file,
folder,
user,
site
};