简体   繁体   English

在“;”之前修复预期的不合格ID 令牌错误

[英]Fix Expected Unqualified id before ';' token error

Rather than compiling, my code is throwing the following error: 我的代码没有编译,而是抛出以下错误:

expected unqualified-id before ‘;’ token
 template std::list<SGAction_MaxMinMax>::iterator;

I've looked at other threads on similar errors, but none seem to address my problem. 我看过其他类似错误的线程,但似乎都没有解决我的问题。

//! Overloaded equality operator
/*!< Returns true if the state and action are the same. */
bool operator==(const SGAction_MaxMinMax & lhs,
                const SGAction_MaxMinMax & rhs);

//! Overloaded comparison operator.
/*!< Returns true if the lhs state is strictly less than the rhs
   state, or if they are equal and the lhs action is strictly less
   than the rhs action/ */
bool operator<(const SGAction_MaxMinMax & lhs,
               const SGAction_MaxMinMax & rhs);

template class std::list<SGAction_MaxMinMax>;
template std::list<SGAction_MaxMinMax>::const_iterator;
template std::list<SGAction_MaxMinMax>::iterator;

The error is on the second to last, and third to last, lines of code above. 错误在上面的倒数第二行和倒数第三行。

template class std::list<SGAction_MaxMinMax>;

This thing is called an explicit template instantination definition . 这件事称为显式模板实例化定义 It makes the compiler instantinate std::list<SGAction_MaxMinMax> , and it causes all methods in std::list<SGAction_MaxMinMax> to be compiled, even if they aren't used. 它使编译器实例化std::list<SGAction_MaxMinMax> ,并导致std::list<SGAction_MaxMinMax>所有方法被编译,即使未使用它们。

You can read more about this rarely used feature here: Explicit instantiation - when is it used? 您可以在此处阅读有关此罕见功能的更多信息: 显式实例化-什么时候使用?


template std::list<SGAction_MaxMinMax>::const_iterator;
template std::list<SGAction_MaxMinMax>::iterator;

These lines don't look like valid C++ to me. 这些行对我来说似乎不是有效的C ++。 It could be an attempt at explicit instantination as well (but class is missing). 也可能是尝试进行显式实例化(但缺少class )。

GCC doesn't compile those even if you add class (because apparently list<T>::iterator and const_iterator are type aliases rather than classes). 即使您添加class GCC也不会编译它们(因为显然list<T>::iteratorconst_iterator是类型别名而不是类)。

Simply removing those two lines might work. 只需删除这两行即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM