Overload operator< for an array of long values
<p>My implementation of the operator&lt; overload does not work properly for my wrapper class around an array of long values.</p>

<p>While using this wrapper class for a Key inside a std::map, calling functions at/find does not work if I mix arrays of different length. </p>

<pre><code>const oid oid1[] = { 1,3,6,1,4,1,42570,1,3,1 };
oid_wrapper wrapper1(oid1, 10);
const oid oid2[] = { 1,3,6,1,4,1,42570,1,3,1,9,1 };
oid_wrapper wrapper1(oid2, 12);
</code></pre>

<p>When adding wrapper1 first and then wrapper2 to the map, it will always find wrapper1 with at/find, but for wrapper2 it throws an out_of_range exception with at and iterator.end with find. 
<br/>
When adding wrapper2 first and then wrapper1 to the map, it will always find wrapper2 with at/find, but for wrapper1 it throws an out_of_range exception with at and iterator.end with find.</p>

<p>The type oid is from Net-SNMP and is actually an unsigned long int.<br/>
So what is my implementation missing or doing completely wrong?
<br/><br/></p>

<pre><code>#include &lt;ostream&gt;
#include &lt;sstream&gt;
#include &lt;net-snmp/net-snmp-config.h&gt;
#include &lt;net-snmp/net-snmp-includes.h&gt;

class oid_wrapper {
public:
    oid_wrapper(const oid* _oid_value, int _oid_length) : oid_value(0), oid_length  (_oid_length) {
        oid_value = snmp_duplicate_objid(_oid_value, oid_length);
    }

    const oid* get_oid() const { return oid_value; }
    const int&amp; get_length() const { return oid_length; }

    /**
     * copy operator overloader
     */
    oid_wrapper&amp; operator=(const oid_wrapper&amp; wrapper) {
        oid_value = snmp_duplicate_objid(wrapper.get_oid(), wrapper.get_length());
        oid_length = wrapper.get_length();

        return *this;
    }

    /**
     * equal operator overloader
     */
    bool operator==(const oid_wrapper&amp; rhs) const {
        const oid* rhs_oid = rhs.get_oid();
        const int rhs_length = rhs.get_length();

        if (netsnmp_oid_equals(oid_value, oid_length, rhs_oid, rhs_length) == 0) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * less-than operator overloader
     */
    bool operator&lt;(const oid_wrapper&amp; rhs) const {
        const oid* rhs_oid = rhs.get_oid();
        const int rhs_length = rhs.get_length();

        if (oid_length &lt; rhs_length) { return true; }

        for (int i = 0; i &lt; oid_length; i++) {
            if (oid_value[i] &lt; rhs_oid[i]) { return true; }
        }

        return false;
    }

    const long getLastNumberInOid() const { return oid_value[oid_length - 1]; }

    bool operator!=(const oid_wrapper&amp; rhs) { return !operator==(rhs); }
    bool operator&gt;(const oid_wrapper&amp; rhs) { return !operator&lt;(rhs); }
    bool operator&lt;=(const oid_wrapper&amp; rhs) { return !operator&gt;(rhs); }
    bool operator&gt;=(const oid_wrapper&amp; rhs) { return !operator&lt;(rhs); }

private:
    const oid* oid_value;
    int oid_length;
};
</code></pre>

<p>This i my testclass I designed to check if it worked:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;ostream&gt;
#include &lt;string&gt;
#include &lt;map&gt;
#include &lt;stdexcept&gt;

#include &lt;net-snmp/net-snmp-config.h&gt;
#include &lt;net-snmp/net-snmp-includes.h&gt;

#include "oid_wrapper.h"

using namespace std;

int main(int argc, char **argv) {

    cout &lt;&lt; "Testing first set of OID" &lt;&lt; endl;
    const oid oid1[] = { 1,3,6,1,4,1,40850,1,3 };
    const oid_wrapper parent1 (oid1, 9);
    const oid_wrapper parent1_child1 (parent1, 40);
    const oid_wrapper parent1_child2 (parent1, 41);
    const oid_wrapper parent1_child3 (parent1, 42);
    const oid_wrapper parent1_child4 (parent1, 43);

    map&lt;oid_wrapper, string&gt; test;
    test.insert(make_pair(parent1_child1, "parent1_child1"));
    test.insert(make_pair(parent1_child2, "parent1_child2"));
    test.insert(make_pair(parent1_child3, "parent1_child3"));
    test.insert(make_pair(parent1_child4, "parent1_child4"));
    if (test.size() != 4) { cout &lt;&lt; "FAIL" &lt;&lt; endl; }
    cout &lt;&lt; "Number of OID in list: " &lt;&lt; test.size() &lt;&lt; endl;

    const oid_wrapper parent11 (oid1, 9);
    const oid_wrapper parent1_child11 (parent11, 40);
    try {
        string teststring = test.at(parent1_child11);
        cout &lt;&lt; "Success" &lt;&lt; endl;
    } catch (out_of_range&amp; e) {
        cout &lt;&lt; "Failure" &lt;&lt; endl;
    }

    const oid_wrapper parent1_child12 (parent11, 41);
    try {
        string teststring = test.at(parent1_child12);
        cout &lt;&lt; "Success" &lt;&lt; endl;
    } catch (out_of_range&amp; e) {
        cout &lt;&lt; "Failure" &lt;&lt; endl;
    }

    const oid_wrapper parent1_child13 (parent11, 42);
    try {
        string teststring = test.at(parent1_child13);
        cout &lt;&lt; "Success" &lt;&lt; endl;
    } catch (out_of_range&amp; e) {
        cout &lt;&lt; "Failure" &lt;&lt; endl;
    }

    const oid_wrapper parent1_child14 (parent11, 43);
    try {
        string teststring = test.at(parent1_child14);
        cout &lt;&lt; "Success" &lt;&lt; endl;
    } catch (out_of_range&amp; e) {
        cout &lt;&lt; "Failure" &lt;&lt; endl;
    }

    cout &lt;&lt; "Testing second set of OID" &lt;&lt; endl;
    const oid oid2[] = { 1,3,6,1,4,1,40850,2,1,9,1 };
    const oid_wrapper parent2 (oid2, 11);
    const oid_wrapper parent2_child1 (parent2, 1);
    const oid_wrapper parent2_child2 (parent2, 2);
    const oid_wrapper parent2_child3 (parent2, 3);
    const oid_wrapper parent2_child4 (parent2, 4);

    test.insert(make_pair(parent2_child1, "parent2_child1"));
    test.insert(make_pair(parent2_child2, "parent2_child2"));
    test.insert(make_pair(parent2_child3, "parent2_child3"));
    test.insert(make_pair(parent2_child4, "parent2_child4"));
    if (test.size() != 8) { cout &lt;&lt; "FAIL" &lt;&lt; endl; }
    cout &lt;&lt; "Number of OID in list: " &lt;&lt; test.size() &lt;&lt; endl;

    const oid_wrapper parent21 (oid2, 11);
    const oid_wrapper parent1_child21 (parent21, 1);
    try {
        string teststring = test.at(parent1_child21);
        cout &lt;&lt; "Success" &lt;&lt; endl;
    } catch (out_of_range&amp; e) {
        cout &lt;&lt; "Failure" &lt;&lt; endl;
    }

    const oid_wrapper parent1_child22 (parent21, 2);
    try {
        string teststring = test.at(parent1_child22);
        cout &lt;&lt; "Success" &lt;&lt; endl;
    } catch (out_of_range&amp; e) {
        cout &lt;&lt; "Failure" &lt;&lt; endl;
    }

    const oid_wrapper parent1_child23 (parent21, 3);
    try {
        string teststring = test.at(parent1_child23);
        cout &lt;&lt; "Success" &lt;&lt; endl;
    } catch (out_of_range&amp; e) {
        cout &lt;&lt; "Failure" &lt;&lt; endl;
    }

    const oid_wrapper parent1_child24 (parent21, 4);
    try {
        string teststring = test.at(parent1_child24);
        cout &lt;&lt; "Success" &lt;&lt; endl;
    } catch (out_of_range&amp; e) {
        cout &lt;&lt; "Failure" &lt;&lt; endl;
    }

    //#################################################

    //Adding 100 OIDs
    for (int i = 0; i &lt; 100; i++) {
        const oid newoid[] = { 1,3,6,1,4,1,40850,2,1,9,1 };
        const oid_wrapper wrapper(newoid, 11, i);
        test.insert(make_pair(wrapper, "wrapper"));
    }

    //Query for the 100 added OIDs
    int run1 = 0;
    for (int i = 0; i &lt; 100; i++) {
        const oid newoid[] = { 1,3,6,1,4,1,40850,2,1,9,1 };
        const oid_wrapper wrapper(newoid, 11, i);

        try {
            string teststring = test.at(wrapper);
            run1++;
        } catch (out_of_range&amp; e) {
            //FAIL
        }
    }
    if (run1 == 100) { cout &lt;&lt; "Run 1 Success" &lt;&lt; endl; }
    else { cout &lt;&lt; "Run 1: " &lt;&lt; run1 &lt;&lt; endl; }

    //#################################################

    //Adding 100 OIDs
    for (int i = 0; i &lt; 100; i++) {
        const oid newoid[] = { 1,3,6,1,4,1,40850,1,3 };
        const oid_wrapper wrapper(newoid, 9, i);
        test.insert(make_pair(wrapper, "wrapper"));
    }

    //Query for the 100 added OIDs
    int run2 = 0;
    for (int i = 0; i &lt; 100; i++) {
        const oid newoid[] = { 1,3,6,1,4,1,40850,1,3 };
        const oid_wrapper wrapper(newoid, 9, i);

        try {
            string teststring = test.at(wrapper);
            run2++;
        } catch (out_of_range&amp; e) {
            //FAIL
        }
    }
    if (run2 == 100) { cout &lt;&lt; "Run 2 Success" &lt;&lt; endl; }
    else { cout &lt;&lt; "Run 2: " &lt;&lt; run2 &lt;&lt; endl; }

    //#################################################

    //Adding 100 OIDs
    for (int i = 0; i &lt; 10; i++) {
        const oid newoid[] = { 1,3,6,1,4,1,40850,2 };
        const oid_wrapper wrapper(newoid, 8, i);
        test.insert(make_pair(wrapper, "wrapper"));
    }

    //Query for the 100 added OIDs
    int run3 = 0;
    for (int i = 0; i &lt; 10; i++) {
        const oid newoid[] = { 1,3,6,1,4,1,40850,2 };
        const oid_wrapper wrapper(newoid, 8, i);

        try {
            string teststring = test.at(wrapper);
            run3++;
        } catch (out_of_range&amp; e) {
            //FAIL
        }
    }
    if (run3 == 10) { cout &lt;&lt; "Run 3 Success" &lt;&lt; endl; }
    else { cout &lt;&lt; "Run 3: " &lt;&lt; run3 &lt;&lt; endl; }

    //#################################################

    //Adding 100 OIDs
    for (int i = 0; i &lt; 100; i++) {
        const oid newoid[] = { 1,3,6,1,4,1,40850,2,2,5,1 };
        const oid_wrapper wrapper(newoid, 11, i);
        test.insert(make_pair(wrapper, "wrapper"));
    }

    //Query for the 100 added OIDs
    int run4 = 0;
    for (int i = 0; i &lt; 100; i++) {
        const oid newoid[] = { 1,3,6,1,4,1,40850,2,2,5,1 };
        const oid_wrapper wrapper(newoid, 11, i);

        try {
            string teststring = test.at(wrapper);
            run4++;
        } catch (out_of_range&amp; e) {
            //FAIL
        }
    }
    if (run4 == 100) { cout &lt;&lt; "Run 4 Success" &lt;&lt; endl; }
    else { cout &lt;&lt; "Run 4: " &lt;&lt; run4 &lt;&lt; endl; }

    //#################################################

    //Adding 100 OIDs
    for (int i = 0; i &lt; 100; i++) {
        const oid newoid[] = { 1,3,6,1,4,1,40850,2,3,5,2 };
        const oid_wrapper wrapper(newoid, 11, i);
        test.insert(make_pair(wrapper, "wrapper"));
    }

    //Query for the 100 added OIDs
    int run5 = 0;
    for (int i = 0; i &lt; 100; i++) {
        const oid newoid[] = { 1,3,6,1,4,1,40850,2,3,5,2 };
        const oid_wrapper wrapper(newoid, 11, i);

        try {
            string teststring = test.at(wrapper);
            run5++;
        } catch (out_of_range&amp; e) {
            //FAIL
        }
    }
    if (run5 == 100) { cout &lt;&lt; "Run 5 Success" &lt;&lt; endl; }
    else { cout &lt;&lt; "Run 5: " &lt;&lt; run5 &lt;&lt; endl; }

    //#################################################

    //Adding 100 OIDs
    for (int i = 0; i &lt; 100; i++) {
        const oid newoid[] = { 1,3,6,1,4,1,40850,2,2,5,2 };
        const oid_wrapper wrapper(newoid, 10, i);
        test.insert(make_pair(wrapper, "wrapper"));
    }

    //Query for the 100 added OIDs
    int run6 = 0;
    for (int i = 0; i &lt; 100; i++) {
        const oid newoid[] = { 1,3,6,1,4,1,40850,2,2,5,2 };
        const oid_wrapper wrapper(newoid, 10, i);

        try {
            string teststring = test.at(wrapper);
            run6++;
        } catch (out_of_range&amp; e) {
            //FAIL
        }
    }
    if (run6 == 100) { cout &lt;&lt; "Run 6 Success" &lt;&lt; endl; }
    else { cout &lt;&lt; "Run 6: " &lt;&lt; run6 &lt;&lt; endl; }

    //#################################################

    //Adding 100 OIDs
    for (int i = 0; i &lt; 100; i++) {
        const oid newoid[] = { 1,3,6,1,4,1,40850,2,5,2,3,5 };
        const oid_wrapper wrapper(newoid, 12, i);
        test.insert(make_pair(wrapper, "wrapper"));
    }

    //Query for the 100 added OIDs
    int run7 = 0;
    for (int i = 0; i &lt; 100; i++) {
        const oid newoid[] = { 1,3,6,1,4,1,40850,2,5,2,3,5 };
        const oid_wrapper wrapper(newoid, 12, i);

        try {
            string teststring = test.at(wrapper);
            run7++;
        } catch (out_of_range&amp; e) {
            //FAIL
        }
    }
    if (run7 == 100) { cout &lt;&lt; "Run 7 Success" &lt;&lt; endl; }
    else { cout &lt;&lt; "Run 7: " &lt;&lt; run7 &lt;&lt; endl; }
}
</code></pre>
