title: C++ compiler converting list to const list
body: <p>This might be something really simple but I can't seem to work it out. Within my <code>Vertex</code> I have a <code>std::list&lt;Edge&gt;</code> but when I try to call methods on it like <code>push_front</code> I get an error saying the <code>list</code> is <code>const</code> and I can't push into it. I think for some reason the compiler is converting the <code>std::list&lt;Edge&gt;</code> to a <code>const std::list&lt;Edge&gt;</code>. I know my code isn't set up very well but it's just homework so I'm taking a few shortcuts.</p>
  
  <p>Header file:</p>
  
  <pre><code>#ifndef GRAPH_H
  #define GRAPH_H
  
  #include &lt;set&gt;
  #include &lt;list&gt;
  
  class Edge{
  public:
      unsigned int to;
      unsigned int weight;
  };
  
  class Vertex{
  public:
      unsigned int id;
      std::list&lt;Edge&gt; edges;
  
      bool operator&lt;(const Vertex&amp; other) const{
          return id &lt; other.id;
      }
  };
  
  class Graph{
  
  public:
      void add_vertex(unsigned int id);
      void add_edge(unsigned int from, unsigned int to, unsigned int weight);
      std::set&lt;Vertex&gt; get_vertices();
      std::list&lt;Edge&gt; get_edges(unsigned int id);
  
  private: 
      std::set&lt;Vertex&gt; _vertices;
      unsigned int size = 0;
  
  
  };
  </code></pre>
  
  <p>Lines causing the error:</p>
  
  <pre><code>void Graph::add_edge(unsigned int from, unsigned int to, unsigned int weight) 
  {
  Vertex find_vert;
  find_vert.id = from;
  set&lt;Vertex&gt;::iterator from_v = _vertices.find(find_vert);
  Edge new_edge;
  new_edge.to = to;
  new_edge.weight = weight;
  
  from_v-&gt;edges.push_front(new_edge); // ERROR HERE
  }
  </code></pre>
  
  <p>Compiler Error message from running <code>g++ -c Graph.cpp</code>:</p>
  
  <pre><code>Graph.cpp:23:38: error: passing ‘const std::list&lt;Edge&gt;’ as ‘this’ argument of ‘void std::list&lt;_Tp,
  _Alloc&gt;::push_front(const value_type&amp;) [with _Tp = Edge; _Alloc = std::allocator&lt;Edge&gt;; std::list&lt;_Tp,
  _Alloc&gt;::value_type = Edge]’ discards qualifiers [-fpermissive]
  </code></pre>