C ++,比较器和模板

时间:2011-01-29 21:53:55

标签: c++ templates comparator

tis代码有什么问题?

template <typename T, template <typename> class GList>
struct TSet
{
    typedef std::set <unsigned int, sortIndices <T, GList> >  Type;  //Error, too many template arguments
};


template <typename T, template <typename> class GList>
class sortIndices 
{

    private:
            const GList <T> *l;

    public:
            sortIndices ( const GList <T> *l_ ) : l ( l_ ) {}

            bool operator() ( const unsigned int &i_p1, const unsigned int &i_p2 ) const
            {
                   ...
            }

};

1 个答案:

答案 0 :(得分:2)

编译好。您需要做的就是:在TSet之后定义sortIndices

亲自看到:http://www.ideone.com/VxBrh
使用::Type的示例:http://www.ideone.com/uRWur