Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add printer for absl::monostate / std::monostate #2066

Open
alexweej opened this issue Jan 18, 2019 · 5 comments
Open

Add printer for absl::monostate / std::monostate #2066

alexweej opened this issue Jan 18, 2019 · 5 comments

Comments

@alexweej
Copy link

We support variant, but it looks like monostate is still printing as 0-byte object.

Propose we print it as {} or (). Hopefully the bikeshedding is not too strong on this one. I think spelling it "monostate" is going to be too verbose where this appears in nested values several times.

@sbenzaquen
Copy link
Collaborator

Printing the type when it is statically known is not that useful. But printing {} is better than "0 byte object..."
I think this is a good change. Feel free to send the PR if you want to do the work.

@gennadiycivil
Copy link
Contributor

Thank you very much for this report. The best way to approach this would be to create a proper PR and submit it for consideration.

@gennadiycivil
Copy link
Contributor

@alex-weej any updates?

@kuzkry
Copy link
Contributor

kuzkry commented Oct 24, 2019

@gennadiycivil, this could be added to #2438 which was rejected (I posted my thoughts on why it should be reconsidered there, but I got no answer). Can I ask you or anyone else to have a second look into that?

@kuzkry
Copy link
Contributor

kuzkry commented Jun 12, 2020

After recent addition of std::variant printer, we'd print a type (if RTTI is available) and a value like this:

// for regular types
std::variant<int> full = 100;
::testing::internal::UniversalPrint(full, &std::cout); // hack for brevity

gives back:
('int(index = 0)' with value 100)

whereas:

// for std::monostate
std::variant<std::monostate> empty;
::testing::internal::UniversalPrint(empty, &std::cout);

returns:
('std::monostate(index = 0)' with value 1-byte object <00>)

The question is whether it's good enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants