FougTools  0.7.0dev-046fb6a
Handy tools for C++, Qt and OpenCascade
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pusher.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** FougTools
3 ** Copyright Fougue (1 Mar. 2011)
4 ** contact@fougue.pro
5 **
6 ** This software is a computer program whose purpose is to provide utility
7 ** tools for the C++ language and the Qt toolkit.
8 **
9 ** This software is governed by the CeCILL-C license under French law and
10 ** abiding by the rules of distribution of free software. You can use,
11 ** modify and/ or redistribute the software under the terms of the CeCILL-C
12 ** license as circulated by CEA, CNRS and INRIA at the following URL
13 ** "http://www.cecill.info".
14 ****************************************************************************/
15 
16 #pragma once
17 
18 #include <iterator>
19 
20 namespace cpp {
21 
41 template <typename CONTAINER>
43  public std::iterator<std::output_iterator_tag, void, void, void, void>
44 {
45 protected:
46  CONTAINER* m_container;
47 
48 public:
49  typedef CONTAINER CONTAINER_type;
50 
51  explicit push_iterator(CONTAINER& x)
52  : m_container(&x)
53  {}
54 
55  push_iterator<CONTAINER>& operator=(const typename CONTAINER::value_type& value)
56  {
57  m_container->push(value);
58  return *this;
59  }
60 
61  push_iterator<CONTAINER>& operator=(typename CONTAINER::value_type&& value)
62  {
63  m_container->push(std::move(value));
64  return *this;
65  }
66 
68  { return *this; }
69 
71  { return *this; }
72 
74  { return *this; }
75 };
76 
84 template<typename CONTAINER>
86 {
87  return push_iterator<CONTAINER>(x);
88 }
89 
90 } // namespace cpp
push_iterator< CONTAINER > & operator++()
Definition: pusher.h:70
Definition: pusher.h:42
push_iterator< CONTAINER > & operator=(typename CONTAINER::value_type &&value)
Definition: pusher.h:61
Definition: basic_shared_pointer.h:20
push_iterator< CONTAINER > & operator*()
Definition: pusher.h:67
push_iterator(CONTAINER &x)
Definition: pusher.h:51
push_iterator< CONTAINER > & operator=(const typename CONTAINER::value_type &value)
Definition: pusher.h:55
CONTAINER CONTAINER_type
Definition: pusher.h:49
push_iterator< CONTAINER > operator++(int)
Definition: pusher.h:73
CONTAINER * m_container
Definition: pusher.h:46
push_iterator< CONTAINER > pusher(CONTAINER &x)
Constructs a push_iterator that pushes new elements into x.
Definition: pusher.h:85