Ensure queue is in ascending order The program reads in a queue of integers and returns determines whether or not it is valid (ascending).
How can this code be improved?
I assume iterator include statement is unnecessary?

#include &lt;iostream&gt;
#include &lt;queue&gt;
#include &lt;deque&gt;
#include &lt;iterator&gt;

template&lt;typename T, typename Container=std::deque&lt;T&gt; &gt;
class iterable_queue : public std::queue&lt;T,Container&gt;
{
public:
    typedef typename Container::iterator iterator;
    typedef typename Container::const_iterator const_iterator;

    iterator begin() { return this-&gt;c.begin(); }
    iterator end() { return this-&gt;c.end(); }
    const_iterator begin() const { return this-&gt;c.begin(); }
    const_iterator end() const { return this-&gt;c.end(); }
};

bool checkValidity(iterable_queue&lt;int&gt;&amp; q) {
    if (q.empty() || q.size() &lt;= 1){
        std::cout &lt;&lt; "invalid entry, insufficient elements" &lt;&lt; '\n';
        return false;
    }
    while(q.size()){
        auto i = q.begin();
        auto j = ++q.begin();
        for(; i &lt; q.end() &amp;&amp; j &lt; ++q.end();){
            std::cout &lt;&lt; *i &lt;&lt; " " &lt;&lt; *j &lt;&lt; '\n';
            if (*(i) &gt; *(j)) {
                std::cout &lt;&lt; "invalid entry, not properly sorted" &lt;&lt; '\n';
                return false;
            }
            i++, j++;
        }   
        std::cout &lt;&lt; "valid entry, properly sorted" &lt;&lt; '\n';
        return true;
    }
    std::cout &lt;&lt; "invalid entry, insufficient elements" &lt;&lt; '\n';
    return false;
}

const char* bool_cast(const bool b) {
    return b ? "true" : "false";
}        

int main () {
    iterable_queue&lt;int&gt; numbers;
    int temp;

    std::cout &lt;&lt; "Pushing..." &lt;&lt; '\n';
    while(temp &gt;= 0){
        std::cout &lt;&lt; "Enter numbers: ";
        std::cin &gt;&gt; temp;
        if(temp &gt;= 0){
            numbers.push(temp);
        }
    }

    bool ck = checkValidity(numbers);
    std::cout &lt;&lt; bool_cast(ck) &lt;&lt; '\n';

    std::cout &lt;&lt; "{ ";
    while(numbers.size() &gt; 0){
        std::cout &lt;&lt; numbers.front();
        numbers.pop();
        std::cout &lt;&lt; " ";
    }
    std::cout &lt;&lt; "}" &lt;&lt; '\n';

    return 0;
}
Queues are not designed to be used like this.  Your iterable_queue clearly shows that you are not using queues the way they are supposed to be used.  And the checkValidity function should be simplified with std::is_sorted from the standard library.  In q.empty() || q.size() &lt;= 1, the first condition is subsumed by the second.  The while(q.size()){ loop also seems to have no significance.  ++q.end() is also undefined behavior.  The bool_cast functionality is already provided by std::boolalpha.

Overall, I think you are seriously over-complicating everything:

#include &lt;algorithm&gt;
#include &lt;iostream&gt;
#include &lt;iterator&gt;
#include &lt;vector&gt;

int main()
{
    std::vector&lt;int&gt; numbers;
    for (int num; std::cin &gt;&gt; num &amp;&amp; num &gt;= 0;) {
        numbers.push_back(num);
    }

    bool valid = numbers.size() &gt; 1 &amp;&amp; std::is_sorted(numbers.begin(), numbers.end());
    std::cout &lt;&lt; "Valid? " &lt;&lt; std::boolalpha &lt;&lt; valid &lt;&lt; '\n';

    std::cout &lt;&lt; "{ ";
    for (int num : numbers) {
        std::cout &lt;&lt; num &lt;&lt; ' ';
    }
    std::cout &lt;&lt; "}\n";
}


(live demo)