title: Exception 'out_of_range' not member of std?
body: <p>I'm trying to write a simple linked-list and am trying to throw an out_of_range exception when the user wants a node index that is out-of-bounds. However, when I compile the source file, I get an error "'out_of_range' is not a member of 'std'".</p>
  
  <p>It was my understanding that 'out_of_range' IS a member of std::, so I assume I am doing something wrong that I am unaware of.</p>
  
  <p>Here is where the error occurs:</p>
  
  <pre><code>T getValueAtIndex (int index)
          {
              // If the index is less than 0 or greater than/equal to
              // the length, throw index out-of-bounds exception.
              if (index &lt; 0 || index &gt;= length)
              {
                  throw std::out_of_range ("Index out of bounds.");
              }
              else 
              {
                  // Start at index 0.
                  int i = 0;
                  // Start with the first node in the list (headNode).
                  Node * currentNode = headNode;
                  // While we have not yet reached the index we want...
                  while (i &lt; index)
                  {
                      currentNode = currentNode-&gt;getNextNode();
                      i++;
                  }
                  return currentNode-&gt;getValue();
              }
          }
  </code></pre>
  
  <p>And here is the entire file so far (not completed yet):</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  template &lt;typename T&gt;
  class LinkedList
  {
      // Private variables/information.
      private:
          // Struct 'Node' which holds the data and a pointer to the next
          // node in the linked-list.
          struct Node {
              T value;
              Node * nextNode;
              // Node constructor, sets nextNode to NULL.
              Node()
              {
                  nextNode = NULL;
              }
              // Sets the value of this node to the value passed to it.
              void setValue (T Value)
              {
                  value = Value;
              }
              void setNextNode (Node * newNode)
              {
                  nextNode = newNode;
              }
              // Returns the value of this node.
              T getValue()
              {
                  return value;
              }
              // Returns a pointer to the next node in the list.
              Node * getNextNode()
              {
                  return nextNode;
              }
          };
          // The head or 'first' node in the list.
          Node * headNode;
          // The tail or 'last' node in the list.
          Node * tailNode;
          // Length of the list. Useful for making sure we 
          // do not search for a node index that is out of bounds.
          int length;
      // Public methods.
      public:
          // Default constructor for the linked list.
          // Initializes the two nodes to NULL.
          LinkedList()
          {
              headNode = NULL;
              tailNode = NULL;
              length = 0;
          }
          // Adds a value to the linked-list as a node.
          void add (T Value)
          {
              // Create a new node on the heap.
              Node newNode = new Node();
              // Set the value of this new node to the value specified.
              newNode.setValue(Value);
  
              // If there is no node in the list yet...
              if (headNode == NULL)
              {
                  // Point headNode and tailNode to the address of newNode.
                  headNode = &amp;newNode;
                  tailNode = &amp;newNode;
              }
              // Else if there is already a node in the list.
              else
              {
                  // Link the new node to the last current node.
                  tailNode-&gt;setNextNode(&amp;newNode);
                  // Set the last node to the new node.
                  tailNode = &amp;newNode;
              }
  
              // Increase the length of the list by one.
              length++;
          }
          // Returns the value of the node at the given index.
          // Starts at index 0 like a normal array.
          T getValueAtIndex (int index)
          {
              // If the index is less than 0 or greater than/equal to
              // the length, throw index out-of-bounds exception.
              if (index &lt; 0 || index &gt;= length)
              {
                  throw std::out_of_range ("Index out of bounds.");
              }
              else 
              {
                  // Start at index 0.
                  int i = 0;
                  // Start with the first node in the list (headNode).
                  Node * currentNode = headNode;
                  // While we have not yet reached the index we want...
                  while (i &lt; index)
                  {
                      currentNode = currentNode-&gt;getNextNode();
                      i++;
                  }
                  return currentNode-&gt;getValue();
              }
          }
  };
  
  int main()
  {
  
  
      return 0;
  }
  </code></pre>
  
  <p>What am I doing incorrectly when throwing the exception? I tried without 'std::', including , and with 'new' in front.</p>