// Matrix Construct // // Copyright (C) Matrix Construct Developers, Authors & Contributors // Copyright (C) 2016-2018 Jason Volk // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice is present in all copies. The // full license for this software is available in the LICENSE file. #pragma once #define HAVE_IRCD_JSON_TUPLE_FOR_EACH_H namespace ircd { namespace json { template typename std::enable_if(), void>::type for_each(const tuple &t, function&& f) {} template typename std::enable_if(), void>::type for_each(tuple &t, function&& f) {} template typename std::enable_if(), void>::type for_each(const tuple &t, function&& f) { f(key(t), val(t)); for_each(t, std::forward(f)); } template typename std::enable_if(), void>::type for_each(tuple &t, function&& f) { f(key(t), val(t)); for_each(t, std::forward(f)); } template void for_each(const tuple &t, const vector_view &mask, function&& f) { std::for_each(std::begin(mask), std::end(mask), [&t, &f] (const auto &key) { at(t, key, [&f, &key] (auto&& val) { f(key, val); }); }); } template void for_each(tuple &t, const vector_view &mask, function&& f) { std::for_each(std::begin(mask), std::end(mask), [&t, &f] (const auto &key) { at(t, key, [&f, &key] (auto&& val) { f(key, val); }); }); } template typename std::enable_if<(i < 0), void>::type rfor_each(const tuple &t, function&& f) {} template typename std::enable_if<(i < 0), void>::type rfor_each(tuple &t, function&& f) {} template() - 1> typename std::enable_if(), void>::type rfor_each(const tuple &t, function&& f) { f(key(t), val(t)); rfor_each(t, std::forward(f)); } template() - 1> typename std::enable_if(), void>::type rfor_each(tuple &t, function&& f) { f(key(t), val(t)); rfor_each(t, std::forward(f)); } } // namespace json } // namespace ircd