title: Standard library function to create array of indices whose corresponding value is a given number
body: <p>I've got a C-style array called <code>board</code> that contains some <code>char</code>'s. I'm trying to create a <code>std::array</code> or <code>std::vector</code> (either would be fine, although <code>std::array</code> would be preferable) to store all the indices of <code>board</code> that are a certain value (in my case, <code>0</code>).<br>
  This code I wrote is functional and works well:</p>
  
  <pre><code>std::vector&lt;int&gt; zeroes;
  zeroes.reserve(16);
  //board has 16 elements, so zeroes.size() will never be larger than 16.
  //I used this reserve for speedup - the compiler doesn't require it.
  for (int i = 0; i &lt; 16; ++i)
  {
      if (board[i] == 0)
      {
          zeroes.push_back(i);
      }
  }
  </code></pre>
  
  <p>However, from past experience, whenever a <code>std</code> function exists that could replace part of my code, it is terser and hence stylistically preferred and also faster. My function seems like a fairly basic operation - I know there is a standard function* to access the index of an array that contains a value when that value only occurs once** in the array. So, is there a standard function to create an array of the indices that contain a value, assuming that more than one such index exists?  </p>
  
  <hr>
  
  <p>* Technically, two nested function calls: <code>int x = std::distance(board, std::find(board, board + 16, 0));</code>. See <a href="https://stackoverflow.com/questions/3909784/how-do-i-find-a-particular-value-in-an-array-and-return-its-index">the accepted answer here</a>.<br>
  ** Well, it still works if more than one index with the desired value is present, but it returns only the first such index, which isn't very useful in my context.</p>
  
  <hr>
  
  <p>Edit:
  As one of the answers misunderstood the question, I'll clarify what I'm seeking. Let's say we have:</p>
  
  <pre><code>char board[16] = {0, 2, 0, 4,
                    2, 4, 8, 2,
                    0, 0, 8, 4,
                    2, 0, 0, 2};
  </code></pre>
  
  <p>Now, the indices which I'm looking for are <code>{0, 2, 8, 9, 13, 14}</code> because <code>board[0] = 0</code>, <code>board[2] = 0</code>, <code>board[8] = 0</code>, etc. and these are the only numbers which satisfy that property.</p>