Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-1541

Specific.hh is over-specialized for standard C++ containers

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Trivial
    • Resolution: Unresolved
    • 1.7.6
    • None
    • c++
    • None

    Description

      The encoders in Specific.hh for the C++ stdlib types like string, vector, etc. are over-specialized and take only specific variations of these templated templates. The specializations of codec_traits should be partial specializations to support std::string, std::vector, std::map, and so on using user-specific allocators and (for std:set and std::map) a user-specific comparator, as Avro has absolutely no reason to care about these details.

      These partial specializations will not require any API incompatible breaks. They'd look something like:

      template <typename T, typename Allocator>
      template <>
      struct codec_traits<std::vector<T, Allocator> > {
      void encode(Encoder& e, const std::vector<T, Allocator>& s)

      { // ... }
      void encode(Encoder& d, std::vector<T, Allocator>& s) { // ... }

      };

      std::string could be the trickier one since it should probably be a partial specialization over the supported variants of basic_string, though partial specialization of std::string, std::u16string, std::u32string, and std::wstring (which can all have custom allocators).

      Don't forget that std::set and std::map can have both a custom allocator and a custom comparator.

      Attachments

        Activity

          People

            thiru_mg Thiruvalluvan M. G.
            wgs_smiddleditch Sean Middleditch
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: