Lines Matching defs:rhs

41     Maybe(const Maybe& rhs);
44 Maybe(const Maybe<U>& rhs);
46 Maybe(Maybe&& rhs);
49 Maybe(Maybe<U>&& rhs);
51 Maybe& operator=(const Maybe& rhs);
54 Maybe& operator=(const Maybe<U>& rhs);
56 Maybe& operator=(Maybe&& rhs);
59 Maybe& operator=(Maybe<U>&& rhs);
94 Maybe& copy(const Maybe<U>& rhs);
97 Maybe& move(Maybe<U>&& rhs);
119 Maybe<T>::Maybe(const Maybe& rhs)
120 : mNothing(rhs.mNothing) {
121 if (!rhs.mNothing) {
122 new (&mStorage) T(reinterpret_cast<const T&>(rhs.mStorage));
128 Maybe<T>::Maybe(const Maybe<U>& rhs)
129 : mNothing(rhs.mNothing) {
130 if (!rhs.mNothing) {
131 new (&mStorage) T(reinterpret_cast<const U&>(rhs.mStorage));
136 Maybe<T>::Maybe(Maybe&& rhs)
137 : mNothing(rhs.mNothing) {
138 if (!rhs.mNothing) {
139 rhs.mNothing = true;
141 // Move the value from rhs.
142 new (&mStorage) T(std::move(reinterpret_cast<T&>(rhs.mStorage)));
143 rhs.destroy();
149 Maybe<T>::Maybe(Maybe<U>&& rhs)
150 : mNothing(rhs.mNothing) {
151 if (!rhs.mNothing) {
152 rhs.mNothing = true;
154 // Move the value from rhs.
155 new (&mStorage) T(std::move(reinterpret_cast<U&>(rhs.mStorage)));
156 rhs.destroy();
161 inline Maybe<T>& Maybe<T>::operator=(const Maybe& rhs) {
163 return copy(rhs);
168 inline Maybe<T>& Maybe<T>::operator=(const Maybe<U>& rhs) {
169 return copy(rhs);
174 Maybe<T>& Maybe<T>::copy(const Maybe<U>& rhs) {
175 if (mNothing && rhs.mNothing) {
178 } else if (!mNothing && !rhs.mNothing) {
179 // We both are something, so assign rhs to us.
180 reinterpret_cast<T&>(mStorage) = reinterpret_cast<const U&>(rhs.mStorage);
182 // We are nothing but rhs is something.
183 mNothing = rhs.mNothing;
185 // Copy the value from rhs.
186 new (&mStorage) T(reinterpret_cast<const U&>(rhs.mStorage));
188 // We are something but rhs is nothing, so destroy our value.
189 mNothing = rhs.mNothing;
196 inline Maybe<T>& Maybe<T>::operator=(Maybe&& rhs) {
198 return move(std::forward<Maybe<T>>(rhs));
203 inline Maybe<T>& Maybe<T>::operator=(Maybe<U>&& rhs) {
204 return move(std::forward<Maybe<U>>(rhs));
209 Maybe<T>& Maybe<T>::move(Maybe<U>&& rhs) {
210 if (mNothing && rhs.mNothing) {
213 } else if (!mNothing && !rhs.mNothing) {
214 // We both are something, so move assign rhs to us.
215 rhs.mNothing = true;
216 reinterpret_cast<T&>(mStorage) = std::move(reinterpret_cast<U&>(rhs.mStorage));
217 rhs.destroy();
219 // We are nothing but rhs is something.
221 rhs.mNothing = true;
223 // Move the value from rhs.
224 new (&mStorage) T(std::move(reinterpret_cast<U&>(rhs.mStorage)));
225 rhs.destroy();
227 // We are something but rhs is nothing, so destroy our value.