我无法指出签名unmatched
和available
重载的任何区别。
错误说 No matching call to addSupport(NestedConnection<Paragraph, NestedConnection<Line, void> >*&)
But the Candidates are addSupport(const NestedConnection<Paragraph, NestedConnection<Line, void> >*&)
(它们可以隐式转换为 const )
error: no matching function for call to ‘NestedConnection<Section, NestedConnection<Paragraph, NestedConnection<Line, void> > >::addSupport(NestedConnection<Paragraph, NestedConnection<Line, void> >*&)’
note: candidates are: void Collection<T>::addSupport(const T*&) [with T = NestedConnection<Paragraph, NestedConnection<Line, void> >]
这就是我正在做的
template<typename T>
class Collection{
public:
typedef T Type;
typedef std::vector<T*> CollectionT;
typedef Collection<T> self;
private:
CollectionT _supports;
public:
void addSupport(const T*& connection){_supports.push_back(connection);};
const CollectionT& supports() const{return _supports;}
};
template<typename T, typename C=void>
class NestedConnection: public Connection<T>, Collection<C>{
public:
typedef T ParentT;
typedef C ChildT;
typedef Connection<T> ConnectionT;
typedef Collection<C> CollectionT;
enum{
leaf = 0
};
public:
NestedConnection(const T* l, const T* r): Connection<T>(l, r){}
};
我通过做来调用
NestedConnection<ParentT, ChildT>* connection = new NestedConnection<ParentT, ChildT>(lhs, rhs);
//This will be unfolded till void and it starts from
//NestedConnection<Section, NestedConnection<Paragraph, NestedConnection<Line, void>>>
connection->addSupport(con_lr);
//con_lr:ChildT*