2010-07-01から1ヶ月間の記事一覧

テンプレートを使っていて、分かりづらかった文法のメモ

C++

引数の char[] 型から文字数を知る まずは、char[] を引数に受けて文字数を知りたい時のテンプレートの書き方。 template<typename CharType, int N> void copy(CharType (&c)[N], const std::string& str) { std::strncpy(c, str.c_str(), N); } 「CharType (&c)[N]」のところがポイン</typename>…