to_chars_result.hpp 883 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2023 Matt Borland
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // https://www.boost.org/LICENSE_1_0.txt
  4. #ifndef BOOST_CHARCONV_DETAIL_TO_CHARS_RESULT_HPP
  5. #define BOOST_CHARCONV_DETAIL_TO_CHARS_RESULT_HPP
  6. #include <system_error>
  7. // 22.13.2, Primitive numerical output conversion
  8. namespace boost { namespace charconv {
  9. struct to_chars_result
  10. {
  11. char *ptr;
  12. std::errc ec;
  13. constexpr friend bool operator==(const to_chars_result &lhs, const to_chars_result &rhs) noexcept
  14. {
  15. return lhs.ptr == rhs.ptr && lhs.ec == rhs.ec;
  16. }
  17. constexpr friend bool operator!=(const to_chars_result &lhs, const to_chars_result &rhs) noexcept
  18. {
  19. return !(lhs == rhs);
  20. }
  21. constexpr explicit operator bool() const noexcept { return ec == std::errc{}; }
  22. };
  23. }} // Namespaces
  24. #endif //BOOST_CHARCONV_DETAIL_TO_CHARS_RESULT_HPP