Use OR instead of AND for all classes that have multiple types.

Revert example. Combination of has_as and not has_as are move to tests.
This commit is contained in:
Takatoshi Kondo
2016-08-29 22:12:01 +09:00
parent 9a2bb0c972
commit 5d69c22bf9
11 changed files with 168 additions and 46 deletions

View File

@@ -109,7 +109,7 @@ struct StdTupleConverter<Tuple, 0> {
namespace adaptor {
template <typename... Args>
struct as<std::tuple<Args...>, typename std::enable_if<msgpack::all_of<msgpack::has_as, Args...>::value>::type> {
struct as<std::tuple<Args...>, typename std::enable_if<msgpack::any_of<msgpack::has_as, Args...>::value>::type> {
std::tuple<Args...> operator()(
msgpack::object const& o) const {
if (o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }

View File

@@ -27,7 +27,7 @@ namespace adaptor {
template <typename K, typename V, typename Hash, typename Compare, typename Alloc>
struct as<
std::unordered_map<K, V, Hash, Compare, Alloc>,
typename std::enable_if<msgpack::has_as<K>::value && msgpack::has_as<V>::value>::type> {
typename std::enable_if<msgpack::has_as<K>::value || msgpack::has_as<V>::value>::type> {
std::unordered_map<K, V, Hash, Compare, Alloc> operator()(msgpack::object const& o) const {
if (o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
msgpack::object_kv* p(o.via.map.ptr);
@@ -100,7 +100,7 @@ struct object_with_zone<std::unordered_map<K, V, Hash, Compare, Alloc>> {
template <typename K, typename V, typename Hash, typename Compare, typename Alloc>
struct as<
std::unordered_multimap<K, V, Hash, Compare, Alloc>,
typename std::enable_if<msgpack::has_as<K>::value && msgpack::has_as<V>::value>::type> {
typename std::enable_if<msgpack::has_as<K>::value || msgpack::has_as<V>::value>::type> {
std::unordered_multimap<K, V, Hash, Compare, Alloc> operator()(msgpack::object const& o) const {
if (o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
msgpack::object_kv* p(o.via.map.ptr);