|
#pragma once
#include <iterator>
#include "../algorithm/push_back.hpp"
namespace tomato {
template< class BackInsertableT >
struct back_insert_iterator
{
typedef std::output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
explicit back_insert_iterator(BackInsertableT& x) : m_x(&x) { }
template< class ValueT >
back_insert_iterator& operator=(ValueT const& val)
{
push_back(*m_x, val);
return *this;
}
back_insert_iterator& operator*() { return *this; }
back_insert_iterator& operator++() { return *this; }
back_insert_iterator& operator++(int) { return *this; }
private:
BackInsertableT *m_x; // must be a pointer for copyable
};
template< class BackInsertableT >
back_insert_iterator<BackInsertableT> back_inserter(BackInsertableT& x)
{
return back_insert_iterator<BackInsertableT>(x);
}
} // namespace tomato
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here