开发者

C++, comparator and template

开发者 https://www.devze.com 2023-02-07 17:00 出处:网络
What is 开发者_高级运维wrong in tis code? template <typename T, template <typename> class GList>

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

精彩评论

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