glaze: invalid documentation

https://github.com/stephenberry/glaze/blob/main/docs/custom-serialization.md Is:

template <>
   struct to_json<uuid_t>
   {
      template <auto Opts>
      static void op(uuid_t& uuid, auto&&... args) noexcept

should be:

template <>
   struct to_json<uuid_t>
   {
      template <auto Opts>
      static void op(uuid_t const & uuid, auto&&... args) noexcept

or

template <>
   struct to_json<uuid_t>
   {
      template <auto Opts>
      static void op(auto && uuid, auto&&... args) noexcept

as uuid_t& uuid will fail with concept write_json_invocable when used as const for example std::span<uuid_t const>

I didnt check this uuid_t but my own non trivial class.

About this issue

  • Original URL
  • State: closed
  • Created 3 months ago
  • Comments: 16 (16 by maintainers)

Most upvoted comments

I have always approach to templates to narrow down error as fast as possible, prevent calling template as soon as possible. As top constraints give nice error message and point to user code, while deep very often even don’t point to user code error line … and this is as case of static_assert(false_v<T> in glaze. Absolutely hard to find place in my code where I made mistake as error refers to only glaze code and the only clue is a type on template after many <false,false… opts …

Yeah, I just created glz::read_json_supported and glz::write_json_supported concepts that allow you to check much more easily in #864. Just merged.

I can add a concept to check if your type is supported. Great idea.

For the writing bit you’re right, I’ll change it to use const in the example.