from unique_ptr<char[]> to unique_ptr<const char[]>
VS2010 and VS2012's stdlib allow conversion with res = std::move(buf)
as an extension and as a response to DR2118. Same goes for libc++ and GCC 4.8's libstdc++.
For GCC 4.7, you won't get around the const_cast
, but atleast you can shorten the line somewhat:
res.reset(const_cast<char const*>(buf.release()));