Skip to content

Instantly share code, notes, and snippets.

@nihil84
nihil84 / ReduCpp@store_factory.hpp
Created February 10, 2019 17:01
utility functions
template <class A>
struct reducpp::reduce {
template <class ...Reducers>
static inline composer<A, Reducers...> with(Reducers ...reducers) {
return composer<A, Reducers...>(reducers...);
}
};
template <class A>
struct reducpp::store_factory {
@nihil84
nihil84 / ReduCpp@composer.hpp
Created February 10, 2019 16:28
The composer functor
template <class A, class ...Reducers>
class reducpp::composer {
public:
using ReducersTuple = std::tuple<std::decay_t<Reducers> ...>;
using CompositeState = std::tuple<typename reducpp::_impl::reducer_traits<Reducers>::state_t ...>;
composer(const Reducers& ...reducers)
: m_reducers(reducers...) { }
CompositeState operator() (const CompositeState& state, const A& action) {
@nihil84
nihil84 / ReduCpp@store.hpp
Last active December 13, 2022 08:53
The store class (simplified)
template <class S, class A>
class reducpp::store {
public:
typedef std::function<S(const S&, const A&)> reducer_t;
typedef std::function<void()> callback_t;
template <class F>
store(const F& reducer) : m_reducer(reducer) { m_history.push_back(S()); }
const S& getState() const { return m_history.back(); }
@nihil84
nihil84 / ReduCpp@basics.cpp
Last active February 8, 2019 15:51
ReduCpp basic usage example
#include <reducpp/store.hpp>
#include <reducpp/action.hpp>
using namespace reducpp;
struct mystate
{
int value;
};
@nihil84
nihil84 / ReduCpp@composite_state.cpp
Created February 8, 2019 15:37
ReduCpp usage example with composite states
#include <reducpp/store.hpp>
#include <reducpp/action.hpp>
#include "../doctest.h"
#include <vector>
using namespace reducpp;
// interface reducpp::action is only a guideline (supports any type of action)
class myaction : public action {
public:
enum TYPE { INCREMENT, DECREMENT };
@nihil84
nihil84 / octgn-on-mac.md
Last active October 7, 2018 22:00 — forked from samuellinde/octgn-on-mac.md
Install OCTGN on a Mac and get it running via Wine

Updated for OCTGN 3.2.75.0

tested on macOS El Capitan 10.11.6

Original version here https://gist.github.com/samuellinde

Disclosure: These instructions are provided as-is. I don't take any responsibility for things that might go wrong (though the worst thing that could happen should be that OCTGN just won't run). I don't have time to support you if things don't work, unfortunately. But hopefully you'll get OCTGN running without needing to use a virtual machine like Parallels or VirtualBox.

Statements like these are commands to be run in the terminal. You should be fine just copying and pasting, just don't miss any characters.