相关疑难解决方法(0)

GCC模板问题

Visual Studio编译此代码很好,但gcc只允许它在没有Template运算符的情况下编译.使用Template运算符,它会出现以下错误:

第29行:错误:预期`;' 在"itrValue"之前

class Test
{
  public:

  Test& operator<<(const char* s) {return *this;} // not implemented yet
  Test& operator<<(size_t      s) {return *this;} // not implemented yet

  Test& operator<< (const std::list<const char*>& strList)
  {
    *this << "count=" << strList.size() << "(";

    for (std::list<const char*>::const_iterator itrValue = strList.begin();
         itrValue != strList.end(); ++itrValue)
    {
        *this << " " << *itrValue;
    }

    *this << ")";

    return *this;
  }

  template <class T>
  Test& operator<< (const std::list<T>& listTemplate)
  {
    *this << "count=" << listTemplate.size() << …
Run Code Online (Sandbox Code Playgroud)

c++ gcc templates

8
推荐指数
2
解决办法
1812
查看次数

标签 统计

c++ ×1

gcc ×1

templates ×1