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
精彩评论