This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int auto_clean() { | |
SOCKET socket = socket(AF_INET, SOCK_STREAM, 0); | |
unique_ptr<SOCKET, void (*)(SOCKET *)> ac(&socket, | |
[](SOCKET *s) { closesocket(*s); }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://gist.github.com/JeffreyZhao/297760dcff8c066606e8 | |
public class Parser<T, TResult> { | |
public static Func<T, TResult> Func = Emit(); | |
private static Func<T, TResult> Emit() { | |
var method = new DynamicMethod(string.Empty, typeof(TResult), new[] { typeof(T) }); | |
var il = method.GetILGenerator(); | |
il.Emit(OpCodes.Ldarg_0); | |
il.Emit(OpCodes.Ret); |