Om
empty_source.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Source_EmptySource_
16 
18 
19 #else
20 
21 // MARK: - Om::Source::EmptySource
22 
23  #define Template_ \
24  template <typename ThisItem>
25 
26  #define Type_ \
27  Om::Source::EmptySource<ThisItem>
28 
29 // MARK: public (static)
30 
31 Template_
32 inline Type_ & Type_::Get() {
33  static Type_ theEmptySource;
34  return theEmptySource;
35 }
36 
37 // MARK: public (non-static)
38 
39 Template_
40 inline Type_::EmptySource() {}
41 
42 Template_
43 inline Type_ & Type_::operator =(EmptySource) {
44  return *this;
45 }
46 
47 Template_
48 inline bool Type_::operator !() const {
49  return true;
50 }
51 
52 Template_
53 inline ThisItem & Type_::operator *() const {
54  assert(0);
55  throw std::logic_error("The source is empty.");
56 }
57 
58 Template_
59 inline bool Type_::Equals(EmptySource const &) const {
60  return true;
61 }
62 
63 Template_
64 inline void Type_::Pop() {
65  assert(0);
66  throw std::logic_error("The source is empty.");
67 }
68 
69 Template_
70 inline void Type_::Swap(EmptySource &) {}
71 
72  #undef Type_
73  #undef Template_
74 
75 // MARK: - Om::Source::
76 
77  #define Template_ \
78  template <typename TheItem>
79 
80  #define Type_ \
81  Om::Source::EmptySource<TheItem>
82 
83 Template_
84 inline bool Om::Source::operator ==(
85  Type_ const &,
86  Type_ const &
87 ) {
88  return true;
89 }
90 
91 Template_
92 inline bool Om::Source::operator !=(
93  Type_ const &,
94  Type_ const &
95 ) {
96  return false;
97 }
98 
99 // MARK: - boost::
100 
101 Template_
102 inline void boost::swap(
103  Type_ & theFirst,
104  Type_ & theSecond
105 ) {
106  theFirst.Swap(theSecond);
107 }
108 
109  #undef Type_
110  #undef Template_
111 
112 #endif
Om header file.
bool operator==(CodePointSource< TheCodeUnitIterator > const &, CodePointSource< TheCodeUnitIterator > const &)
bool operator!=(CodePointSource< TheCodeUnitIterator > const &, CodePointSource< TheCodeUnitIterator > const &)
void swap(Om::Language::Expression &, Om::Language::Expression &)