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

How to format vector of enum values #2262

Closed
AndrewJD79 opened this issue Apr 29, 2021 · 2 comments
Closed

How to format vector of enum values #2262

AndrewJD79 opened this issue Apr 29, 2021 · 2 comments

Comments

@AndrewJD79
Copy link

Is it possible to format std::vector of enum values? A single enum value is formatted as integer just fine but vector won't.

#include <fmt/core.h>
#include <fmt/ranges.h>
#include <vector>

enum ErrorCode : int {
  Value1, Value2, Value3
};

int main() {
  ErrorCode code = Value2;
  fmt::print("{}", code); // ok

  std::vector<ErrorCode> v = {Value1,Value2,Value3};
  fmt::print("{}", fmt::join(v, ",")); // error
}

Thank you

@vitaut
Copy link
Contributor

vitaut commented May 5, 2021

It should Just Work as of f0095cc.

@vitaut vitaut closed this as completed May 5, 2021
@AndrewJD79
Copy link
Author

Thank you!

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

2 participants