title: Can a char* be moved into an std::string?
body: <p>Say I have something like this</p>
  
  <pre><code>extern "C" void make_foo (char** tgt) {
    *tgt = (char*) malloc(4*sizeof(char));
    strncpy(*tgt, "foo", 4);
  }
  
  int main() {
    char* foo;
    make_foo(&amp;foo);
    std::string foos{{foo}};
    free(foo);
    ...
    return 0;
  }
  </code></pre>
  
  <p>Now, I would like to avoid using and then deleting the <code>foo</code> buffer. I.e., I'd like to change the initialisation of <code>foos</code> to something like</p>
  
  <pre><code>  std::string foos{{std::move(foo)}};
  </code></pre>
  
  <p>and use no explicit <code>free</code>.</p>
  
  <p>Turns out this actually compiles and seems to work, but I have a rather suspicious feel about it: does it actually move the C-defined string and properly free the storage? Or does it just ignore the <code>std::move</code> and leak the storage once the <code>foo</code> pointer goes out of scope?</p>
  
  <p>It's not that I worry too much about the extra copy, but I do wonder if it's possible to write this in modern move-semantics style.</p>