title: how to check if queue is sorted using stl
body: <p>i would like your help with this question I have, I need to write a C++ function that inputs a queue as parameter and checks whether the contents in the queue are in sorted order (such that the front element is smallest). A <code>BOOLEAN</code> value should be returned accordingly. Assuming that there is no duplicated element in the queue.<br>
  I am trying to get my head around the concept of sorting, so any help would be appreciated, here is what I have tried so far:</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;queue&gt;
  using namespace std; 
  
  bool is_Sorted(queue&lt;int&gt; q) {
      int my_front = q.front();
      int my_back = q.back();
      if (my_front==my_back) {
          return true;
      }
      if (my_front+1&gt;my_front) {
          return true;
      }
  }
  
  int main()
  {
      queue &lt;int&gt; q;
      q.push(3);
      q.push(4);
      q.push(5);
      q.push(6);
      q.push(7);
      is_Sorted(q);
      return 0;
  }
  </code></pre>