// 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__KEY_TRANSFORM_H namespace ircd { namespace json { template constexpr typename std::enable_if::type _key_transform(it_a it, const it_b &end, closure&& lambda) { return it; } template constexpr typename std::enable_if::type _key_transform(it_a it, const it_b &end, closure&& lambda) { if(it != end) { *it = lambda(key()); ++it; } return _key_transform(it, end, std::forward(lambda)); } template constexpr auto _key_transform(it_a it, const it_b &end) { return _key_transform(it, end, [] (auto&& key) { return key; }); } template auto _key_transform(const tuple &tuple, it_a it, const it_b &end) { for_each(tuple, [&it, &end] (const auto &key, const auto &val) { if(it != end) { *it = key; ++it; } }); return it; } } // namespace json } // namespace ircd