title: OpenCV, C++: Inserting into set
body: <p>I am developing a C++ application using NetBeans 6.9 on Ubuntu 11.04.  I am using OpenCV  2.3.1.  I was wondering if someone could tell me what is wrong with this code.</p>
  
  <p><code>
  void AddTriangle(CvPoint buf[3], set&lt; Triangle > &amp;V)<br>
  {<br>
      Triangle    triangle;<br>
      int         inc;<br></p>
  
  <pre><code>for (inc=0; inc&lt;3; ++inc)
  {
      triangle.v[inc].x=buf[inc].x;
      triangle.v[inc].y=buf[inc].y;
  }
  V.insert((const Triangle) triangle);
  </code></pre>
  
  <p>}
  </code></p>
  
  <p>I get the following error message when I try to compile.</p>
  
  <p><code>
                   from /usr/include/c++/4.5/bits/locale_classes.h:42,<br>
                   from /usr/include/c++/4.5/bits/ios_base.h:43,<br>
                   from /usr/include/c++/4.5/ios:43,<br>
                   from /usr/include/c++/4.5/istream:40,<br>
                   from /usr/include/c++/4.5/sstream:39,<br>
                   from /usr/include/c++/4.5/complex:47,<br>
                   from /usr/local/include/opencv2/core/core.hpp:59,<br>
                   from ../../OpenCV-2.3.1/include/opencv/cv.h:64,<br>
                   from ../../OpenCV-2.3.1/include/opencv/cv.hpp:50,<br>
                   from ../../DraculaFiles/TwoDTriangulation.cpp:12:<br>
  /usr/include/c++/4.5/bits/stl_function.h: In member function ‘bool std::less&lt;_Tp>::operator()(const _Tp&amp;, const _Tp&amp;) const [with _Tp = sTriangle]’:<br>
  In file included from /usr/include/c++/4.5/string:50:0,
  /usr/include/c++/4.5/bits/stl_tree.h:1184:4:   instantiated from ‘std::pair, bool> std::_Rb_tree&lt;_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(const _Val&amp;) [with _Key = sTriangle, _Val = sTriangle, _KeyOfValue = std::_Identity, _Compare = std::less, _Alloc = std::allocator]’<br>
  /usr/include/c++/4.5/bits/stl_set.h:408:29:   instantiated from ‘std::pair, _Compare, typename _Alloc::rebind&lt;_Key>::other>::const_iterator, bool> std::set&lt;_Key, _Compare, _Alloc>::insert(const value_type&amp;) [with _Key = sTriangle, _Compare = std::less, _Alloc = std::allocator, typename std::_Rb_tree&lt;_Key, _Key, std::_Identity&lt;_Key>, _Compare, typename _Alloc::rebind&lt;_Key>::other>::const_iterator = std::_Rb_tree_const_iterator, value_type = sTriangle]’
  </code></p>
  
  <p>Triangle is defined as follows.</p>
  
  <p><code></p>
  
  <p>typedef struct sTriangle<br>
  {<br>
          CvPoint v[3];<br>
  } Triangle;
  </code></p>
  
  <p>Any help would be greatly appreciated,<br>
  Peter.</p>