/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright 2021, Danny Robson */ #pragma once #include #include #include /////////////////////////////////////////////////////////////////////////////// namespace cruft::iterator { /// An output iterator that calls insert on a supplied container template struct unordered_insert { public: using iterator_category = std::output_iterator_tag; using value_type = void; using difference_type = void; using pointer = void; using reference = void; unordered_insert (ContainerT &_target) : m_target (&_target) { ; } unordered_insert& operator++ () { return *this; } unordered_insert& operator * () { return *this; } unordered_insert& operator-> () { return this; } template unordered_insert& operator= (ValueT &&val) { m_target->insert (std::forward (val)); return *this; } private: ContainerT *m_target; }; template unordered_insert (ContainerT &) -> unordered_insert>; }