Search code examples
c++boostuuid

Convert boost::uuid to char*


I am looking to convert a boost::uuid to a const char*. What is the correct syntax for the conversion?


Solution

  • You can do this a bit easier using boost::lexical_cast that uses a std::stringstream under the hood.

    #include <boost/lexical_cast.hpp>
    #include <boost/uuid/uuid_io.hpp>
    
    const std::string tmp = boost::lexical_cast<std::string>(theUuid);
    const char * value = tmp.c_str();