/** ** \file misc/vector.hh ** \brief Declaration of misc::vector */ #pragma once #include #include #include namespace misc { template class vector : public std::vector { public: /// Super class type. using super_type = std::vector; /// \name Constructors and destructor. /// \{ /// Build an empty vector. vector(); /// Build a one-element vector. vector(const Ident_& t); /// Build a two-element vector. vector(const Ident_& t1, const Ident_& t2); /// Concat an element and a vector. vector(const Ident_& t, const vector& v); // Build a vector from an initializer list. vector(std::initializer_list l); /// Build a vector from 2 iterators. template vector(InputIterator b, InputIterator e); /// Build a vector fro, another container. template vector(const C& c); /// \} /// \name Content management. /// \{ /// Is \a data part of \a this vector? bool has(const Ident_& data) const; /// Prepend \a v into \a this and return the new iterator. typename super_type::iterator prepend(const vector& v); typename super_type::iterator prepend(const vector&& v); /// Append \a v into \a this and return the new iterator. typename super_type::iterator append(const vector& v); typename super_type::iterator append(const vector&& v); /// Append \a v into \a this. vector operator+(const vector& v) const; /// Append \a v into \a this. vector& operator+=(const vector& v); /// Append \a v into \a this from it and return the new iterator. template typename super_type::iterator position_append(const vector& v, Iterator it); template typename super_type::iterator position_append(const vector&& v, Iterator it); /** \brief Remove \a data from \a this. \a data must be part of \a this. */ vector& remove(const Ident_& data); /// \} virtual std::ostream& dump(std::ostream& ostr) const; }; /// Output \a v onto \a ostr. template std::ostream& operator<<(std::ostream& ostr, const vector& v); template auto append_and_move(std::vector& res, std::vector&& to_append); template auto append_and_move(std::vector& res, std::vector& to_append); template auto prepend_and_move(std::vector& res, std::vector&& to_prepend); template auto prepend_and_move(std::vector& res, std::vector& to_prepend); template auto position_append_and_move(std::vector& res, Iterator res_iterator, std::vector&& to_append); template auto position_append_and_move(std::vector& res, Iterator res_iterator, std::vector& to_append); } // namespace misc #include