crend.cpp 413 B

12345678910111213141516171819
  1. #include <iostream>
  2. #include <nlohmann/json.hpp>
  3. using json = nlohmann::json;
  4. int main()
  5. {
  6. // create an array value
  7. json array = {1, 2, 3, 4, 5};
  8. // get an iterator to the reverse-end
  9. json::const_reverse_iterator it = array.crend();
  10. // increment the iterator to point to the first element
  11. --it;
  12. // serialize the element that the iterator points to
  13. std::cout << *it << '\n';
  14. }