Last active
March 15, 2019 06:55
-
-
Save benlau/bc2f458a9e85f6a1a1d25c1505a07a49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename Object, typename Source, typename Iteratee> | |
inline Object assignWith(Object& object, const Source & source, Iteratee iteratee ) { | |
using source_info = _::Private::key_value_info<Source>; | |
using object_info = _::Private::key_value_info<Object>; | |
_underline_static_assert_is_iteratee_invokable("_::assignWith: ", (_::Private::is_invokable5<Iteratee, | |
typename object_info::value_type, | |
typename source_info::value_type, | |
typename source_info::key_type, | |
Object, Source>::value)); | |
forIn(source, [&](const typename source_info::value_type& value, | |
const typename source_info::key_type& key) { | |
auto ret = Private::invoke(iteratee, | |
Private::read(object, key), | |
value, | |
key, | |
object, | |
source); | |
Private::write(object, key, ret); | |
}); | |
return object; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment