How do I construct a std::string from a DWORD?

前端 未结 8 2278
死守一世寂寞
死守一世寂寞 2020-12-07 00:30

I have following code:

Tools::Logger.Log(string(GetLastError()), Error);

GetLastError() returns a DWORD a numeric

8条回答
  •  不知归路
    2020-12-07 01:00

    As all guys here suggested, implementation will use stringstream.
    In my current project we created function

    template 
    std::string util::str::build( const T& value );
    

    to create string from any source.

    So in our project it would be

    Tools::Logger.Log( util::str::build(GetLastError()) );
    

    Such usage of streams in the suggested way wouldn't pass my review unless someone wrap it.

提交回复
热议问题