As I understand it, before C++20 iterators were just a concept defined by the standard. Now in C++20 they are real language concepts which are checked at compile time. I'm wondering if I'm safe to assume that I can consume a C++20 iterator in my API and pass it to any pre-C++20 API without it breaking:
#include <string>
#include <concepts>
#include <cstdio>
#include <utility>
auto write_string(std::input_iterator auto it) -> void { // <-- C++20 iterator
std::string ret = "Danger";
std::copy(ret.begin(), ret.end(), it); // <-- requires LegacyInputIterator
}
int main()
{
std::string str = "Austin is my middle name";
write_string(str.begin());
printf("%.*s\n", (int)str.size(), str.data());
}