Skip to content

Instantly share code, notes, and snippets.

@Danielmelody
Danielmelody / StateMachine.cs
Last active August 7, 2016 01:30
Simple State Machine for Generally Use in C#
// Simple State Machine with clever transition-event management
// created by yiminghu:github.com/Danielhu
using System.Collections.Generic;
public class StateMachine<StateType>{
public delegate void TransitionDelegate();
@Danielmelody
Danielmelody / lambda_RAII.cpp
Last active December 7, 2020 08:08
RAII cleaner in one line
{
// resources are easy to gain by capture, and use in the destructor
std::shared_ptr<int> cleaner(nullptr, [some_captures](int *) { do_something(); });
}