2009-02-01から1ヶ月間の記事一覧

型配列

c++

複数の型をlistに束縛してnthで取り出してみる。 中身はlispちっくにconsセルでつなげてます。 #include <iostream> #include <typeinfo> struct nil_t {}; template <typename... args> struct cons_cell; template <typename first, typename... rest> struct cons_cell<first, rest...> { typedef first car; typedef cons_cell<rest...> cdr; }; template </rest...></first,></typename></typename...></typeinfo></iostream>

variadic template事始め

c++

C++0xでvariadic templateを使って可変数引数の数を数えるプログラムを組んでみる。 使ったのはg++ Ubuntu 4.3.2-1ubuntu12 オプションは g++ -g -Wall -std=c++0x -o variadic_templ variadic_templ.cpp #include <iostream> #include <typeinfo> template <typename... arg> struct length; temp</typename...></typeinfo></iostream>…