title: cannot append to LinkedList implementation
body: <p>I sketched up this small single linked list example. But for some reason, new node do not get appended to the list correctly.
  Can someone help me by detecting the error please?</p>
  <pre><code>struct Node {
    Node(int x, Node *next = nullptr) : x{x}, next{next} {}
    int x;
    std::shared_ptr&lt;Node&gt; next;
  };
  
  class LinkedList {
  public:
    LinkedList(std::vector&lt;int&gt; const &amp;v) {
      for (auto i = 0; i &lt; std::size(v); ++i) {
        auto temp = std::make_shared&lt;Node&gt;(v[i], nullptr);
        if (head == nullptr) {
          head = temp;
        } else {
          auto ptr = head;
          while (ptr != nullptr) {
            ptr = ptr-&gt;next;
          }
          ptr = temp;
        }
      }
    }
  
    std::shared_ptr&lt;Node&gt; head = nullptr;
  };
  
  
  int main() {
    auto v = std::vector&lt;int&gt;{1, 2, 3};
    auto l = LinkedList{v};
  }
  </code></pre>