how to create conditional breakpoint with std::string

前端 未结 11 1004
粉色の甜心
粉色の甜心 2020-12-07 12:54

Suppose I have this function:

std::string Func1(std::string myString)
{
   //do some string processing 
   std::string newString = Func2(myString)
   return          


        
11条回答
  •  粉色の甜心
    2020-12-07 13:53

    Some searching has failed to turn up any way to do this. Suggested alternatives are to put the test in your code and add a standard breakpoint:

    if (myStr == "xyz")
    {
        // Set breakpoint here
    }
    

    Or to build up your test from individual character comparisons. Even looking at individual characters in the string is a bit dicey; in Visual Studio 2005 I had to dig down into the member variables like

    myStr._Bx._Buf[0] == 'x' && myStr._Bx._Buf[1] == 'y' && myStr._Bx._Buf[2] == 'z'
    

    Neither of these approaches is very satisfactory. We should have better access to a ubiquitous feature of the Standard Library.

提交回复
热议问题