#define
にダブルコロンを使用できますか?実装ファイルにいくつかの文章を保存したいと思います。#defineにダブルコロン(::)を使用
// foo.h
#define template template <class T>
#define foo:: foo<T>::
template class foo {
T& baz();
};
#include "foo.tpp"
#undef template
#undef foo::
// foo.tpp
template T& foo::baz() {
// do stuff.
}
しかし、私は実際にはわからない構文エラーが発生します。 (codepad上の例を参照):
Line 11: error: missing whitespace after the macro name
Line 10: error: extra tokens at end of #undef directive
Line 4: error: 'foo' is not a template
compilation terminated due to -Wfatal-errors.
よくある質問ですが、文法エラーも投稿しています –
それはうまくいかなかったようです。誰もあなたのコードを理解したり維持したりすることはできません。あなたの後継者はあなたの肖像にピンをつけます。 – TonyK