I am looking to convert a boost::uuid to a const char*. What is the correct syntax for the conversion?
+1
A:
You can include <boost/uuid/uuid_io.hpp>
and then use the operators to convert a uuid into a std::stringstream
. From there, it's a standard conversion to a const char*
as needed.
For details, see the Input and Output second of the Uuid documentation.
std::stringstream ss;
ss << theUuid;
const std::string tmp = ss.str();
const char * value = tmp.c_str();
(For details on why you need the "tmp" string, see here.)
Reed Copsey
2010-08-10 18:55:22
A:
You use the stream functions in boost/uuid/uuid_io.hpp.
boost::uuids::uuid u;
std::stringstream ss;
ss << u;
ss >> u;
Joe
2010-08-10 18:56:34