2

I am working on a C++ project for which would be really useful to see the string representation of variables in VScode's variable inspector.

How can I implement a custom representation of variables in the inspector? I have already tried overloading the << operator, but with no success.

// in header file
std::ostream& operator<<(std::ostream& stream, Tokens::Token const& token);

// in implementation file
std::ostream& operator<<(std::ostream& stream, Tokens::Token const& token)
{   
    // write representation to stream
    return stream;
}

I know there are no errors in the operator<< function because printing to the console via std::cout << *token << std::endl; works fine.

This is what I would like to achieve

Expected behaviour

Thanks in advance

Nicholas Obert
  • 1,235
  • 1
  • 13
  • 29

0 Answers0