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

The format_to functions claim OutputIterator support but actually expect a back_insert_iterator #1506

Closed
mikezackles opened this issue Jan 4, 2020 · 5 comments

Comments

@mikezackles
Copy link

Thanks for a useful library!

As best I can tell, both container_type and operator= are specific to back_insert_iterator, and not a part of OutputIterator. So these functions don't actually support output iterators.

It seems like either the code needs to be modified to use just the OutputIterator operations or the documentation should be updated.

@mikezackles
Copy link
Author

mikezackles commented Jan 4, 2020

(Note that I ran into this using format_to_n. Perhaps it is just specific to internal::truncating_iterator?)

@vitaut
Copy link
Contributor

vitaut commented Jan 5, 2020

format_to_n supports iterators other than back_insert_iterator, e.g.

#include <fmt/format.h>

int main() {
  char buf[10];
  fmt::format_to_n(buf, 10, "{}", 42);
}

https://godbolt.org/z/Pg_aQ_

@vitaut vitaut closed this as completed Jan 5, 2020
@mikezackles
Copy link
Author

My mistake, I should've given an example: https://godbolt.org/z/_edHPs

@vitaut
Copy link
Contributor

vitaut commented Jan 5, 2020

Thanks for the example. Should be fixed in 9e3f3e8.

@vitaut vitaut closed this as completed Jan 5, 2020
@mikezackles
Copy link
Author

Awesome, 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