#define
에 이중 콜론을 사용할 수 있습니까? 구현 파일에 일부 글을 저장하고 싶습니다. like :#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