15 [[nodiscard]]
auto getIn(T &&item)
17 return std::forward<T>(item);
20 template<
class ImmerT,
class K,
class ...Keys>
21 [[nodiscard]]
auto getIn(ImmerT &&container, K &&key, Keys &&...keys)
23 return getIn(std::forward<ImmerT>(container)[std::forward<K>(key)], std::forward<Keys>(keys)...);
27 [[nodiscard]]
auto setIn(T, T newVal)
32 template<
class ImmerT,
class K>
33 [[nodiscard]]
auto setIn(ImmerT container, std::decay_t<decltype(
getIn(std::declval<ImmerT>(), std::declval<K>()))> newVal, K &&key) -> std::decay_t<ImmerT>
35 return std::move(container).set(std::forward<K>(key), std::move(newVal));
38 template<
class ImmerT,
class K,
class ...Keys>
39 [[nodiscard]]
auto setIn(ImmerT container, std::decay_t<decltype(
getIn(std::declval<ImmerT>(), std::declval<K>(), std::declval<Keys>()...))> newVal, K &&key, Keys &&...keys) -> std::decay_t<ImmerT>
41 auto oldItem =
getIn(container, key);
42 return std::move(container).set(
44 setIn(oldItem, std::move(newVal), std::forward<Keys>(keys)...)
48 template<
class T,
class Func>
49 [[nodiscard]]
auto updateIn(T oldVal, Func func) -> T
51 return std::move(func)(oldVal);
54 template<
class ImmerT,
class Func,
class ...Keys>
55 [[nodiscard]]
auto updateIn(ImmerT container, Func func, Keys &&...keys) -> ImmerT
57 auto oldVal =
getIn(container, keys...);
58 auto newVal = std::move(func)(std::move(oldVal));
59 return setIn(std::move(container), std::move(newVal), std::forward<Keys>(keys)...);
Definition: location.hpp:10
auto setIn(T, T newVal)
Definition: immer-utils.hpp:27
auto updateIn(T oldVal, Func func) -> T
Definition: immer-utils.hpp:49
auto getIn(T &&item)
Definition: immer-utils.hpp:15