【ISO/ANSI/JIS】 C言語なら俺に聞け! Part 132at TECH
【ISO/ANSI/JIS】 C言語なら俺に聞け! Part 132 - 暇つぶし2ch464:デフォルトの名無しさん
07/11/28 20:13:12
アルゴリズムだけ書いた

/* template/strcpy.cpp */
#ifdef XCS_IS_CHAR
#define char_t char
#define xcscpy_ strcpy
#define text_( text ) text
#endif

#ifdef XCS_IS_WCHAR
#define char_t wchar_t
#define xcscpy_ wcscpy
#define text_( text ) L ## text
#endif

/* strcpy, wcscpy */
char_t *xcscpy_( char_t *dst_, const char_t *src_ ){
char_t *head = dst_; while( text_('\0') != (*dst_++ = *src_++) ){ /* nop */; } return head;
}

のようなテンプレートを用意して

/* strcpy.cpp */
#define XCS_IS_WCHAR
#include <template/strcpy.cpp>

/* wcscpy.cpp */
#define XCS_IS_CHAR
#include <template/strcpy.cpp>

と読み込ませるので、どちらが良いと思いますか?
あるいは、もっと良い方法がありますか?


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch