gpt4 book ai didi

C++、比较器和模板

转载 作者:行者123 更新时间:2023-11-30 04:36:01 27 4
gpt4 key购买 nike

这个代码有什么问题?

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

};

最佳答案

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

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

关于C++、比较器和模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4839690/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com