Om
container_back_source.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Source_ContainerBackSource_
16 
18 
19 #else
20 
21 // MARK: - Om::Source::ContainerBackSource
22 
23  #define Template_ \
24  template < \
25  typename ThisItem, \
26  typename ThisContainer \
27  >
28 
29  #define Type_ \
30  Om::Source::ContainerBackSource< \
31  ThisItem, \
32  ThisContainer \
33  >
34 
35 // MARK: public (non-static)
36 
37 Template_
38 inline Type_::ContainerBackSource(ThisContainer & theContainer):
39 thisContainer(theContainer) {}
40 
41 Template_
42 inline Type_ & Type_::operator =(ContainerBackSource theContainerBackSource) {
43  this->Swap(theContainerBackSource);
44  return *this;
45 }
46 
47 Template_
48 inline bool Type_::operator !() const {
49  return this->thisContainer.empty();
50 }
51 
52 Template_
53 inline ThisItem & Type_::operator *() const {
54  assert(
55  !this->thisContainer.empty()
56  );
57  return this->thisContainer.back();
58 }
59 
60 Template_
61 inline bool Type_::Equals(ContainerBackSource const & theContainerBackSource) const {
62  return (
63  &this->thisContainer == &theContainerBackSource.thisContainer ||
64  (
65  this->thisContainer.empty() &&
66  theContainerBackSource.thisContainer.empty()
67  )
68  );
69 }
70 
71 Template_
72 inline void Type_::Pop() {
73  assert(
74  !this->thisContainer.empty()
75  );
76  this->thisContainer.pop_back();
77 }
78 
79 Template_
80 inline void Type_::Swap(ContainerBackSource & theContainerBackSource) {
82  this->thisContainer,
83  theContainerBackSource.thisContainer
84  );
85 }
86 
87  #undef Type_
88  #undef Template_
89 
90 // MARK: - Om::Source::
91 
92  #define Template_ \
93  template < \
94  typename TheItem, \
95  typename TheContainer \
96  >
97 
98  #define Type_ \
99  Om::Source::ContainerBackSource< \
100  TheItem, \
101  TheContainer \
102  >
103 
104 Template_
105 inline bool Om::Source::operator ==(
106  Type_ const & theFirst,
107  Type_ const & theSecond
108 ) {
109  return theFirst.Equals(theSecond);
110 }
111 
112 Template_
113 inline bool Om::Source::operator !=(
114  Type_ const & theFirst,
115  Type_ const & theSecond
116 ) {
117  return !theFirst.Equals(theSecond);
118 }
119 
120 // MARK: - boost::
121 
122 Template_
123 inline void boost::swap(
124  Type_ & theFirst,
125  Type_ & theSecond
126 ) {
127  theFirst.Swap(theSecond);
128 }
129 
130  #undef Type_
131  #undef Template_
132 
133 #endif
bool operator==(CodePointSource< TheCodeUnitIterator > const &, CodePointSource< TheCodeUnitIterator > const &)
bool operator!=(CodePointSource< TheCodeUnitIterator > const &, CodePointSource< TheCodeUnitIterator > const &)
void swap(Om::Language::Expression &, Om::Language::Expression &)