avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Middleditch (JIRA)" <j...@apache.org>
Subject [jira] [Created] (AVRO-1541) Specific.hh is over-specialized for standard C++ containers
Date Sat, 12 Jul 2014 00:58:04 GMT
Sean Middleditch created AVRO-1541:
--------------------------------------

             Summary: Specific.hh is over-specialized for standard C++ containers
                 Key: AVRO-1541
                 URL: https://issues.apache.org/jira/browse/AVRO-1541
             Project: Avro
          Issue Type: Bug
          Components: c++
    Affects Versions: 1.7.6
            Reporter: Sean Middleditch
            Priority: Trivial


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.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message