开发者

C++, comparator and template

What is 开发者_高级运维wrong in tis code?

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
            {
                   ...
            }

};


It compiles fine. All you need to do is this : define TSet after sortIndices.

See this yourself: http://www.ideone.com/VxBrh
Example that uses ::Type : http://www.ideone.com/uRWur

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜