title: find position of a 2D vector which is an element of a class C++
body: <p>I am working on a class that I have some problems in finding positions of values in one of elements of the class. I have defined my class as follows:</p>
  
  <pre><code>typedef class Chrom                                         
  {
   public:
      vector&lt;vector &lt; int&gt;&gt; bit;                  
      vector&lt;vector &lt; bool&gt;&gt; jobisconsidered;
  
      vector&lt;vector &lt;float&gt;&gt; WaitingTime; 
      void variablesresize()
      {
          int i = 0, j, k;
          float a;
  
          std::vector&lt;float&gt; datapoints;
          std::ifstream myfile("Input.dat", std::ios_base::in);
  
          i = 0;                   //making zero counter of characters                        
          myfile.open("Input.dat");//now we reread numerical values                       
  
          while (!myfile.eof())
          {
              myfile &gt;&gt; a;
              //  cout &lt;&lt; "i=" &lt;&lt; i &lt;&lt; '\n';              
              if (!myfile) // not an int                  
              {
                  myfile.clear(); // clear error status               
                  myfile.ignore(1); // skip one char at input             
              }
              else
              {
                  datapoints.push_back(a);
                  ++i;
              }
          }
  
          myfile.close();
  
          Jobs = datapoints[0];
          Machines = datapoints[1];
  
          WaitingTime.resize(Machines);
          bit.resize(Machines);
  
          for (int i = 0; i &lt; Machines - 1; ++i)  WaitingTime[i].resize(Jobs);
  
          bit[i].resize(Jobs);
          }
      }
  } c;
  
  c popcurrent[50];
  </code></pre>
  
  <p>In the class, bit is a 2D element and if I define it as <code>m*n</code>, all values in the rows are the same. However, when I want to find position in <code>bit</code>, for example if <code>popcurrent[0].bit</code> for 2 rows and 3 columns is = <code>{ {3,2,1},{3,2,1} }</code>, and I want to find position of the first "<code>3</code>" in the vector is 0 and <code>popcurrent[0].bit[0][0]=3</code> , I have problems. </p>
  
  <p>Specificaly I tried <a href="https://stackoverflow.com/questions/21977703/c-search-a-vector-for-element-first-seen-position/" title="c++ search a vector for element first seen position">c++ search a vector for element first seen position</a> with the following commands:</p>
  
  <pre><code>auto p = std::lower_bound(popcurrent[0].bit.begin(), popcurrent[0].bit.end(), 1);
  int position = p - popcurrent[0].bit.begin();
  </code></pre>
  
  <p>But I get following error:</p>
  
  <pre><code> Error  109 error C2893: Failed to specialize function template
  'unknown-type std::less&lt;void&gt;::operator ()(_Ty1 &amp;&amp;,_Ty2 &amp;&amp;) const'
  </code></pre>
  
  <p>I know one way is to use for and if loops. But I wonder is there any more automated way to do this such as build in functions.</p>