【发布时间】:2014-12-01 16:11:57
【问题描述】:
我正在寻找 http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/parser/Lexer.h 和 http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/parser/Lexer.cpp
在第196行的标题中,有一段代码
template <bool shouldBuildIdentifiers> ALWAYS_INLINE JSTokenType parseIdentifier(JSTokenData*, unsigned lexerFlags, bool strictMode);
我可以在 cpp 文件中看到一个 实现
template <>
template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType Lexer<LChar>::parseIdentifier(JSTokenData* tokenData, unsigned lexerFlags, bool strictMode)
我对语法的理解是,我们正在为 LChar 类型的 Lexer 定义/专门化函数。它是否正确? 我读到 (Why can templates only be implemented in the header file?) 理想情况下这应该在头文件中完成。
旧的 C++ 编译器也支持这种语法吗?我的是 mips-linux-g++ v 4.1.0。我收到“模板 ID 与任何模板声明都不匹配”
【问题讨论】: