title: Adding vector to NS2; Compiler error
body: <p>I tried to add  <code># include &lt;vector&gt;</code> to a NS2 simulator file but i'm facing problems. 
  i'm getting this error (I've used another computer with g++ 4.6 rather than old g++ 4.4). 
  why only including <code>&lt;vector&gt;</code> causes error? </p>
  
  <pre><code>`g++ -c -Wall -Wno-write-strings  -DTCP_DELAY_BIND_ALL -DNO_TK -DTCLCL_CLASSINSTVAR  -DNDEBUG -DLINUX_TCP_HEADER -DUSE_SHM -DHAVE_LIBTCLCL -DHAVE_TCLCL_H -DHAVE_LIBOTCL1_14 -DHAVE_OTCL_H -DHAVE_LIBTK8_5 -DHAVE_TK_H -DHAVE_LIBTCL8_5 -DHAVE_TCLINT_H -DHAVE_TCL_H  -DHAVE_CONFIG_H -DNS_DIFFUSION -DSMAC_NO_SYNC -DCPP_NAMESPACE=std -DUSE_SINGLE_ADDRESS_SPACE -Drng_test  -I. -I. -I/home/ns235/ns-allinone-2.35/tclcl-1.20 -I/home/ns235/ns-allinone-2.35/otcl -I/home/ns235/ns-allinone-2.35/include -I/home/ns235/ns-allinone-2.35/include -I/home/ns235/ns-allinone-2.35/include -I/usr/include/pcap -I./tcp -I./sctp -I./common -I./link -I./queue -I./adc -I./apps -I./mac -I./mobile -I./trace -I./routing -I./tools -I./classifier -I./mcast -I./diffusion3/lib/main -I./diffusion3/lib -I./diffusion3/lib/nr -I./diffusion3/ns -I./diffusion3/filter_core -I./asim/ -I./qs -I./diffserv -I./satellite -I./wpan -o tcp/tcp-fack.o tcp/tcp-fack.cc
  In file included from /usr/include/c++/4.6/vector:61:0,
               from tcp/tcp-fack.cc:28:
   /usr/include/c++/4.6/bits/stl_algobase.h: In function ‘const _Tp&amp; std::max(const _Tp&amp;, const _Tp&amp;) [with _Tp = TracedInt]:
  tcp/tcp-fack.cc:87:37:   instantiated from here
    /usr/include/c++/4.6/bits/stl_algobase.h:215:7: error: no match for ‘operator&lt;’ in ‘__a  &lt; __b’
   /usr/include/c++/4.6/bits/stl_algobase.h:215:7: note: candidates are:
   /usr/include/c++/4.6/bits/stl_algobase.h:215:7: note: operator&lt;(int, int) &lt;built-in&gt;
   /usr/include/c++/4.6/bits/stl_algobase.h:215:7: note:   no known conversion for argument 2 from ‘const TracedInt’ to ‘int’
  /usr/include/c++/4.6/bits/stl_pair.h:207:5: note: template&lt;class _T1, class _T2&gt; bool std::operator&lt;(const std::pair&lt;_T1, _T2&gt;&amp;, const std::pair&lt;_T1, _T2&gt;&amp;)
   /usr/include/c++/4.6/bits/stl_iterator.h:291:5: note: template&lt;class _Iterator&gt; bool std::operator&lt;(const std::reverse_iterator&lt;_Iterator&gt;&amp;, const std::reverse_iterator&lt;_Iterator&gt;&amp;)
   /usr/include/c++/4.6/bits/stl_iterator.h:341:5: note: template&lt;class _IteratorL, class _IteratorR&gt; bool std::operator&lt;(const std::reverse_iterator&lt;_IteratorL&gt;&amp;, const   std::reverse_iterator&lt;_IteratorR&gt;&amp;)
   /usr/include/c++/4.6/bits/stl_vector.h:1290:5: note: template&lt;class _Tp, class _Alloc&gt;   bool std::operator&lt;(const std::vector&lt;_Tp, _Alloc&gt;&amp;, const std::vector&lt;_Tp, _Alloc&gt;&amp;)
  make: *** [tcp/tcp-fack.o] Error 1
  </code></pre>
  
  <p>here is a snippet of stl_algobase.h lines (197-218).  Is using <code>templete</code> in tcp-fack.cc causing the error? (<a href="http://www.cs.rit.edu/usr/local/pub/swm/gcc-4.7.2/include/c++/4.7.2/bits/stl_algobase.h" rel="nofollow">http://www.cs.rit.edu/usr/local/pub/swm/gcc-4.7.2/include/c++/4.7.2/bits/stl_algobase.h</a>)</p>
  
  <pre><code>/**
  *  @brief This does what you think it does.
  *  @ingroup sorting_algorithms
  *  @param  __a  A thing of arbitrary type.
  *  @param  __b  Another thing of arbitrary type.
  *  @return   The greater of the parameters.
  *
  *  This is the simple classic generic implementation.  It will work on
  *  temporary expressions, since they are only evaluated once, unlike a
  *  preprocessor macro.
  */
  
  template&lt;typename _Tp&gt;
  inline const _Tp&amp;
  max(const _Tp&amp; __a, const _Tp&amp; __b)
  {
    // concept requirements
    __glibcxx_function_requires(_LessThanComparableConcept&lt;_Tp&gt;)
    //return  __a &lt; __b ? __b : __a;
    if (__a &lt; __b)
  return __b;
    return __a;
  }
  </code></pre>
  
  <p><strong>below is a snippet of tcp-fack.cc</strong>.Here is the original file with line number <a href="https://github.com/hbatmit/ns2.35/blob/master/tcp/tcp-fack.cc" rel="nofollow">https://github.com/hbatmit/ns2.35/blob/master/tcp/tcp-fack.cc</a> ( I only added <code>&lt;vector&gt;</code> at line 28)</p>
  
  <pre><code>#ifndef lint
  static const char rcsid[] =
  "@(#) /home/ctk21/cvsroot//hssstcp/ns/ns-2.1b9/tcp/tcp-fack.cc,v 1.2 2002/08/12 10:43:58     ctk21 Exp (PSC)";
  #endif
  
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;vector&gt;   //line 28
  #include "ip.h"
  #include "tcp.h"
  #include "flags.h"
  #include "scoreboard.h"
  #include "random.h"
  #include "tcp-fack.h"
  #include "template.h"
  
  static class FackTcpClass : public TclClass {
  public:
  FackTcpClass() : TclClass("Agent/TCP/Fack") {}
  TclObject* create(int, const char*const*) {
      return (new FackTcpAgent());
      }
   } class_fack;
  
  
  /*
   * Process a dupack.
   */
  void FackTcpAgent::oldack(Packet* pkt)
  {
  hdr_tcp *tcph = hdr_tcp::access(pkt);
  
  last_ack_ = tcph-&gt;seqno();
  highest_ack_ = last_ack_;
  fack_ = max(fack_,highest_ack_);
  /* 
   * There are conditions under which certain versions of TCP (e.g., tcp-fs)
   * retract maxseq_. The following line of code helps in those cases. For
   * versions of TCP, it is a NOP.
       */
  maxseq_ = max(maxseq_, highest_ack_);// This is line 87
  if (t_seqno_ &lt; last_ack_ + 1)
      t_seqno_ = last_ack_ + 1; // This is line 89 
  newtimer(pkt);
  if (rtt_active_ &amp;&amp; tcph-&gt;seqno() &gt;= rtt_seq_) { 
      rtt_active_ = 0;
      t_backoff_ = 1;
  }
  /* with timestamp option */
  double tao = Scheduler::instance().clock() - tcph-&gt;ts_echo();
  rtt_update(tao);
  if (ts_resetRTO_) {
      // From Andrei Gurtov
      // FACK has not been updated to make sure the ECN works
      //   correctly in this case - Sally.
      t_backoff_ = 1;
  }
  /* update average window */
  awnd_ *= 1.0 - wnd_th_;
  awnd_ += wnd_th_ * cwnd_;
  /* if the connection is done, call finish() */
  if ((highest_ack_ &gt;= curseq_-1) &amp;&amp; !closed_) {
      closed_ = 1;
      finish();
  }
  }
  
  int FackTcpAgent::maxsack(Packet *pkt)
  {
  hdr_tcp *tcph = hdr_tcp::access(pkt);
  int maxsack=-1, sack_index; 
  
  for (sack_index=0; sack_index &lt; tcph-&gt;sa_length(); sack_index++) {
      if (tcph-&gt;sa_right(sack_index) &gt; maxsack)
          maxsack = tcph-&gt;sa_right(sack_index);
  }
  return (maxsack-1);
  }
  </code></pre>
  
  <p>** I have replaced <code>&lt;vector&gt;</code> with <code>&lt;map&gt;</code> and it showed the following error **</p>
  
  <pre><code>g++ -c -Wall -Wno-write-strings  -DTCP_DELAY_BIND_ALL -DNO_TK -DTCLCL_CLASSINSTVAR  -DNDEBUG -DLINUX_TCP_HEADER -DUSE_SHM -DHAVE_LIBTCLCL -DHAVE_TCLCL_H -DHAVE_LIBOTCL1_14 -DHAVE_OTCL_H -DHAVE_LIBTK8_5 -DHAVE_TK_H -DHAVE_LIBTCL8_5 -DHAVE_TCLINT_H -DHAVE_TCL_H  -DHAVE_CONFIG_H -DNS_DIFFUSION -DSMAC_NO_SYNC -DCPP_NAMESPACE=std -DUSE_SINGLE_ADDRESS_SPACE -Drng_test  -I. -I. -I/home/ns235/ns-allinone-2.35/tclcl-1.20 -I/home/ns235/ns-allinone-2.35/otcl -I/home/ns235/ns-allinone-2.35/include -I/home/ns235/ns-allinone-2.35/include -I/home/ns235/ns-allinone-2.35/include -I/usr/include/pcap -I./tcp -I./sctp -I./common -I./link -I./queue -I./adc -I./apps -I./mac -I./mobile -I./trace -I./routing -I./tools -I./classifier -I./mcast -I./diffusion3/lib/main -I./diffusion3/lib -I./diffusion3/lib/nr -I./diffusion3/ns -I./diffusion3/filter_core -I./asim/ -I./qs -I./diffserv -I./satellite -I./wpan -o tcp/tcp-fack.o tcp/tcp-fack.cc
  In file included from /usr/include/c++/4.6/bits/stl_tree.h:63:0,
               from /usr/include/c++/4.6/map:60,
               from tcp/tcp-fack.cc:28:
  /usr/include/c++/4.6/bits/stl_algobase.h: In function ‘const _Tp&amp; std::max(const _Tp&amp;, const _Tp&amp;) [with _Tp = TracedInt]’:
  tcp/tcp-fack.cc:87:37:   instantiated from here
  /usr/include/c++/4.6/bits/stl_algobase.h:215:7: error: no match for ‘operator&lt;’ in ‘__a &lt; __b’
  /usr/include/c++/4.6/bits/stl_algobase.h:215:7: note: candidates are:
  /usr/include/c++/4.6/bits/stl_algobase.h:215:7: note: operator&lt;(int, int) &lt;built-in&gt;
  /usr/include/c++/4.6/bits/stl_algobase.h:215:7: note:   no known conversion for argument 2 from ‘const TracedInt’ to ‘int’
  /usr/include/c++/4.6/bits/stl_pair.h:207:5: note: template&lt;class _T1, class _T2&gt; bool  std::operator&lt;(const std::pair&lt;_T1, _T2&gt;&amp;, const std::pair&lt;_T1, _T2&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_iterator.h:291:5: note: template&lt;class _Iterator&gt; bool std::operator&lt;(const std::reverse_iterator&lt;_Iterator&gt;&amp;, const std::reverse_iterator&lt;_Iterator&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_iterator.h:341:5: note: template&lt;class _IteratorL, class _IteratorR&gt; bool std::operator&lt;(const std::reverse_iterator&lt;_IteratorL&gt;&amp;, const std::reverse_iterator&lt;_IteratorR&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_tree.h:866:5: note: template&lt;class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc&gt; bool std::operator&lt;(const std::_Rb_tree&lt;_Key, _Val, _KeyOfValue, _Compare, _Alloc&gt;&amp;, const std::_Rb_tree&lt;_Key, _Val, _KeyOfValue, _Compare, _Alloc&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_map.h:899:5: note: template&lt;class _Key, class _Tp, class _Compare, class _Alloc&gt; bool std::operator&lt;(const std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;&amp;, const std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_multimap.h:817:5: note: template&lt;class _Key, class _Tp, class _Compare, class _Alloc&gt; bool std::operator&lt;(const std::multimap&lt;_Key, _Tp, _Compare, _Alloc&gt;&amp;, const std::multimap&lt;_Key, _Tp, _Compare, _Alloc&gt;&amp;)
  make: *** [tcp/tcp-fack.o] Error 1
  </code></pre>