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
// 今手元に variadic templates をサポートした gcc がない(なんなら gcc 自体ない)からコンパイルが試せていない | |
// f 0 0 = [0] | |
// f n 0 = [] | |
// f n m = n : f n m - 1 | |
// g n = f n n | |
// h n = foldl (++) [] $ map g (0 .. n) | |
template <int... seq> | |
struct ilist; |
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
auto f(tag_type t) -> val { | |
switch (t) { | |
case A: return a(); | |
case B: return b(); | |
... | |
default: assert(false); /* return ??? */ | |
} | |
assert(false); | |
/* return ??? */ | |
} |
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
#include <tuple> | |
#include <functional> | |
#include <cstdio> | |
using namespace std; | |
template <typename T> | |
struct tuple_head; | |
template <typename Head, typename... Tail> | |
struct tuple_head<tuple<Head, Tail...>> { typedef Head type; }; |
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
まず | |
AAA | |
BBB | |
みたいなのじゃ困る、という要求があって | |
process { | |
lock m | |
modify v |
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
template <bool cond, typename _, typename else_> | |
struct enable_if { typedef typename else_::type type; }; | |
template <typename then_, typename _> | |
struct enable_if<true, then_, _>{ typedef typename then_::type type; }; | |
template <int n> | |
struct num { | |
static const int value = n; | |
typedef num<n> type; | |
}; |
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
#include <cstdio> | |
#include <iostream> | |
#include <typeinfo> | |
#include <cxxabi.h> | |
char* demangle(const char *demangle) { | |
int status; | |
return abi::__cxa_demangle(demangle, 0, 0, &status); | |
} |
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
#include <cstdio> | |
template <typename... seq> | |
struct array; | |
template <typename ary> | |
struct head; | |
template <typename first, typename... rest> | |
struct head<array<first, rest...>> { |
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
--- ls-files.c 2010-07-02 00:29:48.206993409 +0900 | |
+++ ls-files.c.orig 2010-07-02 00:29:41.022986503 +0900 | |
@@ -13,6 +13,7 @@ | |
#include "parse-options.h" | |
#include "resolve-undo.h" | |
#include "string-list.h" | |
+#include "color.h" | |
static int abbrev; | |
static int show_deleted; |
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
// せつめい | |
// C++ 0x で (T1, T2, ... TN) -> R を T1 -> (T2 -> ... TN)..) -> Ret する curry を実装した。 | |
// tuple に引数を溜めていき、最後に apply を利用して関数を呼び出す。 | |
// decltype は再帰関数のシグネチャには使えないので返値型を計算する type function を書いた。 | |
// enable_if で頑張れば書けそうだけれど(apply 可能かどうか)面倒なのでジェネリックには実装していない。 | |
#include <tuple> | |
#include <type_traits> | |
#include <functional> |
NewerOlder