错误:"<"令牌之前的预期初始值设定项 |全球

error: expected initializer before '<' token | global

本文关键字:全球 lt 令牌 错误      更新时间:2023-10-16

我有一个类的模板,像这样:

template <template <class, class> class ContainerType>

并且在private字段中设置了一些全局函数和静态函数。

我在类之外实现了我的这些函数,在任何函数之前我声明模板

template <template <class, class> class ContainerType>

但是对于这样一个函数,我得到了这个错误:

错误:'<'标记前期望初始化项

    template<template<class, class> class ContainerType>
    void Book<ContainerType>::listCopier(const List_to_copy<ContainerType>& that)
    {
        if(mylist.begin() != mylist.end())
            std::for_each(mylist.begin(), mylist.end(), DeleteLIST());
        _this = this;
        std::for_each(that.mylist.begin(), that.mylist.end(), myAllocator);
    }

它可以是什么,我如何解决它!?

Try

 template<template<class, class> class ContainerType>
 void Book::listCopier(const List_to_copy<ContainerType>& that)
 { ... }