0
votes

I have a class with a template like this:

template <template <class, class> class ContainerType>

And I set some global functions and static in the private field ..

I achieved my these functions outside the class and before any function I declare the template

template <template <class, class> class ContainerType>

But with such a function for all I get this error:

error: expected initializer before '<' token

    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);
    }

What it can be and how I solve it!?

1
Read the chapter about templates would be a good start - Ed Heal
Does it NEED to be nested like that? - polarysekt
I read it ! But I do not know what causes this problem ... - מג'ד שרקייה
@מג'דשרקייה please post a minimal code snippet that we can attempt to compile and reproduces the issue. What you have above is non-valid. It does not declare or define a class/function. Your snippet is part of a declaration. Look here for an example that works. - vsoftco
@polarysekt : What do you mean !? - מג'ד שרקייה

1 Answers

2
votes

Try

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