/** * https://quuxplusone.github.io/blog/2019/02/06/arrow-proxy/ */ #pragma once namespace iterator::detail { template struct arrow_proxy { arrow_proxy(Reference r) : r(std::move(r)) {} Reference r; Reference * operator->() { return std::addressof(r); } }; template arrow_proxy(R r) -> arrow_proxy; template struct value_proxy { value_proxy operator=(Value && value) { this->value = std::move(value); return *this; } operator Value const &() const { return value; } Value const & get() const { return value; } Value value; }; template struct value_proxy { value_proxy operator=(Value & value) { this->value = &value; return *this; } operator Value &() const { return *value; } Value & get() const { return *value; } Value * value; }; struct ignore_proxy { template decltype(auto) operator=(Value && value) { return std::forward(value); } }; }