0

unmatchedの署名とavailableオーバーロードの違いを指摘することはできません。

エラーには No matching call to と表示されますaddSupport(NestedConnection<Paragraph, NestedConnection<Line, void> >*&)が、候補はaddSupport(const NestedConnection<Paragraph, NestedConnection<Line, void> >*&)( they can be convert to const implicitly )

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*
4

1 に答える 1

1

は暗黙的T*に に変換できますが、を にconst T*バインドすることはできません。参照が参照である場合は可能です。T*const T*&constconst T* const&

于 2012-08-07T05:42:17.157 に答える