C2784 triggered by STL::Set insert() and find()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Olumide

    C2784 triggered by STL::Set insert() and find()

    Hello,

    I've got this nice inner class that I'm holds a set of "FrontPoint "
    objects as shown below. Unfortunately, the find and insert methods
    trigger massive C2784 errors. Would someone please point out what I'm
    doing wrong?

    Many thanks,

    - Olumide


    //////////////////////// code ////////////////////////

    struct FrontPoint
    {
    // stuff
    };

    class Cell
    {
    public:
    double xMin , xMax, yMin, yMax , zMin , zMax;
    Cell *upper , *lower , *north, *south, *east , *west;
    Cell::Cell(){ upper = lower = north = south = east = west = NULL; }
    set<FrontPoint frontPoint;

    void addFrontPoint( FrontPoint& frontPt )
    {
    frontPoint.inse rt( frontPt ); // Triggers C2784
    }

    void removeFrontPoin t( FrontPoint& frontPt )
    {
    set<FrontPoint >::iterator frontPtItx =
    frontPoint.find ( frontPt ); // Triggers C2784
    }
    };


    //////////////////////// error ////////////////////////

    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const
    std::basic_stri ng<_Elem,_Trait s,_Alloc&,const _Elem *)' : could not
    deduce template argument for 'const
    std::basic_stri ng<_Elem,_Trait s,_Ax&' from 'const
    MarchingTriangl es::FrontPoint'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \string(148) : see declaration of 'std::operator` <''
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(138 ) : while compiling class-template member function
    'bool std::less<_Ty>: :operator ()(const _Ty &,const _Ty &) const'
    with
    [
    _Ty=MarchingTri angles::FrontPo int
    ]
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \set(48) : see reference to class template instantiation
    'std::less<_Ty> ' being compiled
    with
    [
    _Ty=MarchingTri angles::FrontPo int
    ]
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \xtree(23) : see reference to class template instantiation
    'std::_Tset_tra its<_Kty,_Pr,_A lloc,_Mfl>' being compiled
    with
    [
    _Kty=MarchingTr iangles::FrontP oint,
    _Pr=std::less<M archingTriangle s::FrontPoint>,
    _Alloc=std::all ocator<Marching Triangles::Fron tPoint>,
    _Mfl=false
    ]
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \xtree(65) : see reference to class template instantiation
    'std::_Tree_nod <_Traits>' being compiled
    with
    [

    _Traits=std::_T set_traits<Marc hingTriangles:: FrontPoint,std: :less<MarchingT riangles::Front Point>,std::all ocator<Marching Triangles::Fron tPoint>,false>
    ]
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \xtree(87) : see reference to class template instantiation
    'std::_Tree_ptr <_Traits>' being compiled
    with
    [

    _Traits=std::_T set_traits<Marc hingTriangles:: FrontPoint,std: :less<MarchingT riangles::Front Point>,std::all ocator<Marching Triangles::Fron tPoint>,false>
    ]
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \xtree(105) : see reference to class template instantiation
    'std::_Tree_val <_Traits>' being compiled
    with
    [

    _Traits=std::_T set_traits<Marc hingTriangles:: FrontPoint,std: :less<MarchingT riangles::Front Point>,std::all ocator<Marching Triangles::Fron tPoint>,false>
    ]
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \set(57) : see reference to class template instantiation
    'std::_Tree<_Tr aits>' being compiled
    with
    [

    _Traits=std::_T set_traits<Marc hingTriangles:: FrontPoint,std: :less<MarchingT riangles::Front Point>,std::all ocator<Marching Triangles::Fron tPoint>,false>
    ]
    c:\Work\Project \MuscleBuilder\ MarchingTriangl es.h(72) : see
    reference to class template instantiation 'std::set<_Kty> ' being
    compiled
    with
    [
    _Kty=MarchingTr iangles::FrontP oint
    ]
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const _Elem
    *,const std::basic_stri ng<_Elem,_Trait s,_Alloc&)' : could not deduce
    template argument for 'const T1 *' from 'const
    MarchingTriangl es::FrontPoint'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \string(138) : see declaration of 'std::operator` <''
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const
    std::basic_stri ng<_Elem,_Trait s,_Alloc&,const
    std::basic_stri ng<_Elem,_Trait s,_Alloc&)' : could not deduce
    template argument for 'const std::basic_stri ng<_Elem,_Trait s,_Ax&'
    from 'const MarchingTriangl es::FrontPoint'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \string(128) : see declaration of 'std::operator` <''
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const
    std::list<_Ty,_ Alloc&,const std::list<_Ty,_ Alloc&)' : could not
    deduce template argument for 'const std::list<_Ty,_ Ax&' from 'const
    MarchingTriangl es::FrontPoint'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \list(991) : see declaration of 'std::operator` <''
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const
    std::_Tree<_Tra its&,const std::_Tree<_Tra its&)' : could not deduce
    template argument for 'const std::_Tree<_Tra its&' from 'const
    MarchingTriangl es::FrontPoint'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \xtree(1170) : see declaration of 'std::operator` <''
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const
    std::vector<_Ty ,_Alloc&,const std::vector<_Ty ,_Alloc&)' : could
    not deduce template argument for 'const std::vector<_Ty ,_Ax&' from
    'const MarchingTriangl es::FrontPoint'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \vector(915) : see declaration of 'std::operator` <''
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const
    std::reverse_it erator<_RanIt&, const std::reverse_it erator<_RanIt>
    &)' : could not deduce template argument for 'const
    std::reverse_it erator<_RanIt&' from 'const
    MarchingTriangl es::FrontPoint'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \xutility(655) : see declaration of 'std::operator` <''
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const
    std::pair<_Ty1, _Ty2&,const std::pair<_Ty1, _Ty2&)' : could not
    deduce template argument for 'const std::pair<_Ty1, _Ty2&' from
    'const MarchingTriangl es::FrontPoint'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \utility(73) : see declaration of 'std::operator` <''
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2676: binary '<' : 'const
    MarchingTriangl es::FrontPoint' does not define this operator or a
    conversion to a type acceptable to the predefined operator
    MarchingTriangl es.cpp
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const
    std::basic_stri ng<_Elem,_Trait s,_Alloc&,const _Elem *)' : could not
    deduce template argument for 'const
    std::basic_stri ng<_Elem,_Trait s,_Ax&' from 'const
    MarchingTriangl es::FrontPoint'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \string(148) : see declaration of 'std::operator` <''
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(138 ) : while compiling class-template member function
    'bool std::less<_Ty>: :operator ()(const _Ty &,const _Ty &) const'
    with
    [
    _Ty=MarchingTri angles::FrontPo int
    ]
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \set(48) : see reference to class template instantiation
    'std::less<_Ty> ' being compiled
    with
    [
    _Ty=MarchingTri angles::FrontPo int
    ]
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \xtree(23) : see reference to class template instantiation
    'std::_Tset_tra its<_Kty,_Pr,_A lloc,_Mfl>' being compiled
    with
    [
    _Kty=MarchingTr iangles::FrontP oint,
    _Pr=std::less<M archingTriangle s::FrontPoint>,
    _Alloc=std::all ocator<Marching Triangles::Fron tPoint>,
    _Mfl=false
    ]
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \xtree(65) : see reference to class template instantiation
    'std::_Tree_nod <_Traits>' being compiled
    with
    [

    _Traits=std::_T set_traits<Marc hingTriangles:: FrontPoint,std: :less<MarchingT riangles::Front Point>,std::all ocator<Marching Triangles::Fron tPoint>,false>
    ]
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \xtree(87) : see reference to class template instantiation
    'std::_Tree_ptr <_Traits>' being compiled
    with
    [

    _Traits=std::_T set_traits<Marc hingTriangles:: FrontPoint,std: :less<MarchingT riangles::Front Point>,std::all ocator<Marching Triangles::Fron tPoint>,false>
    ]
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \xtree(105) : see reference to class template instantiation
    'std::_Tree_val <_Traits>' being compiled
    with
    [

    _Traits=std::_T set_traits<Marc hingTriangles:: FrontPoint,std: :less<MarchingT riangles::Front Point>,std::all ocator<Marching Triangles::Fron tPoint>,false>
    ]
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \set(57) : see reference to class template instantiation
    'std::_Tree<_Tr aits>' being compiled
    with
    [

    _Traits=std::_T set_traits<Marc hingTriangles:: FrontPoint,std: :less<MarchingT riangles::Front Point>,std::all ocator<Marching Triangles::Fron tPoint>,false>
    ]
    c:\Work\Project \MuscleBuilder\ MarchingTriangl es.h(72) : see
    reference to class template instantiation 'std::set<_Kty> ' being
    compiled
    with
    [
    _Kty=MarchingTr iangles::FrontP oint
    ]
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const _Elem
    *,const std::basic_stri ng<_Elem,_Trait s,_Alloc&)' : could not deduce
    template argument for 'const T1 *' from 'const
    MarchingTriangl es::FrontPoint'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \string(138) : see declaration of 'std::operator` <''
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const
    std::basic_stri ng<_Elem,_Trait s,_Alloc&,const
    std::basic_stri ng<_Elem,_Trait s,_Alloc&)' : could not deduce
    template argument for 'const std::basic_stri ng<_Elem,_Trait s,_Ax&'
    from 'const MarchingTriangl es::FrontPoint'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \string(128) : see declaration of 'std::operator` <''
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const
    std::vector<_Ty ,_Alloc&,const std::vector<_Ty ,_Alloc&)' : could
    not deduce template argument for 'const std::vector<_Ty ,_Ax&' from
    'const MarchingTriangl es::FrontPoint'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \vector(915) : see declaration of 'std::operator` <''
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const
    std::list<_Ty,_ Alloc&,const std::list<_Ty,_ Alloc&)' : could not
    deduce template argument for 'const std::list<_Ty,_ Ax&' from 'const
    MarchingTriangl es::FrontPoint'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \list(991) : see declaration of 'std::operator` <''
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const
    std::_Tree<_Tra its&,const std::_Tree<_Tra its&)' : could not deduce
    template argument for 'const std::_Tree<_Tra its&' from 'const
    MarchingTriangl es::FrontPoint'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \xtree(1170) : see declaration of 'std::operator` <''
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const
    std::reverse_it erator<_RanIt&, const std::reverse_it erator<_RanIt>
    &)' : could not deduce template argument for 'const
    std::reverse_it erator<_RanIt&' from 'const
    MarchingTriangl es::FrontPoint'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \xutility(655) : see declaration of 'std::operator` <''
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const
    std::pair<_Ty1, _Ty2&,const std::pair<_Ty1, _Ty2&)' : could not
    deduce template argument for 'const std::pair<_Ty1, _Ty2&' from
    'const MarchingTriangl es::FrontPoint'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \utility(73) : see declaration of 'std::operator` <''
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2676: binary '<' : 'const
    MarchingTriangl es::FrontPoint' does not define this operator or a
    conversion to a type acceptable to the predefined operator

  • red floyd

    #2
    Re: C2784 triggered by STL::Set insert() and find()

    Olumide wrote:
    Hello,
    >
    I've got this nice inner class that I'm holds a set of "FrontPoint "
    objects as shown below. Unfortunately, the find and insert methods
    trigger massive C2784 errors. Would someone please point out what I'm
    doing wrong?
    >
    Among other things, you're not posting a minimal compilable example
    which exhibits the behavior in question -- see FAQ 5.8 --

    >
    //////////////////////// code ////////////////////////
    >
    struct FrontPoint
    {
    // stuff
    };
    >
    class Cell
    {
    public:
    double xMin , xMax, yMin, yMax , zMin , zMax;
    Cell *upper , *lower , *north, *south, *east , *west;
    Cell::Cell(){ upper = lower = north = south = east = west = NULL; }
    set<FrontPoint frontPoint;
    >
    void addFrontPoint( FrontPoint& frontPt )
    {
    frontPoint.inse rt( frontPt ); // Triggers C2784
    }
    >
    void removeFrontPoin t( FrontPoint& frontPt )
    {
    set<FrontPoint >::iterator frontPtItx =
    frontPoint.find ( frontPt ); // Triggers C2784
    }
    };
    >
    >
    //////////////////////// error ////////////////////////
    >
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e
    \functional(139 ) : error C2784: 'bool std::operator <(const
    std::basic_stri ng<_Elem,_Trait s,_Alloc&,const _Elem *)' : could not
    deduce template argument for 'const
    std::basic_stri ng<_Elem,_Trait s,_Ax&' from 'const
    MarchingTriangl es::FrontPoint'
    OK, Where and what is MarchingTriangl es?
    [remainder redacted]

    Comment

    • Olumide

      #3
      Re: C2784 triggered by STL::Set insert() and find()

      I've got this nice inner class that ... holds a set of "FrontPoint "
      objects as shown below. Unfortunately, the find and insert methods
      trigger massive C2784 errors. Would someone please point out what I'm
      doing wrong?
      >
      Among other things, you're not posting a minimal compilable example
      which exhibits the behavior in question -- see FAQ 5.8 --http://www.parashift.c om/c++-faq-lite/how-to-post.html#faq-5.8
      >
      ...
      >
      OK, Where and what is MarchingTriangl es?
      [remainder redacted]
      Oops ... Its the name of the parent class of 'FrontPoint' and 'Cell',
      and its quite complex, but it worked perfectly, at least it did until
      I added add and remove methods to the inner class 'Cell'. Anyway, I
      may have solved the problem, by overloading < in the 'FrontPoint',
      which I had to change from a struct to a class like so:

      class FrontPoint
      {
      public:
      // stuff

      bool operator<( const FrontPoint &frontPt );
      friend bool operator<(const FrontPoint& frontPt1 , const FrontPoint&
      frontPt2 );
      };


      Interestingly, the code compiles even though, the both "operator<"
      methods aren't (yet) implemented. I wonder if I can get away with not
      implementing them ... I'm not trying to be cheeky. I just want to know
      if the error is due to a fussy compiler that wrongly assumes these
      methods will be called.





      Comment

      Working...