Lines Matching defs:rhs

44   Maybe(const Maybe& rhs);
47 Maybe(const Maybe<U>& rhs); // NOLINT(implicit)
49 Maybe(Maybe&& rhs);
52 Maybe(Maybe<U>&& rhs); // NOLINT(implicit)
54 Maybe& operator=(const Maybe& rhs);
57 Maybe& operator=(const Maybe<U>& rhs);
59 Maybe& operator=(Maybe&& rhs);
62 Maybe& operator=(Maybe<U>&& rhs);
99 Maybe& copy(const Maybe<U>& rhs);
102 Maybe& move(Maybe<U>&& rhs);
122 Maybe<T>::Maybe(const Maybe& rhs) : nothing_(rhs.nothing_) {
123 if (!rhs.nothing_) {
124 new (&storage_) T(reinterpret_cast<const T&>(rhs.storage_));
130 Maybe<T>::Maybe(const Maybe<U>& rhs) : nothing_(rhs.nothing_) {
131 if (!rhs.nothing_) {
132 new (&storage_) T(reinterpret_cast<const U&>(rhs.storage_));
137 Maybe<T>::Maybe(Maybe&& rhs) : nothing_(rhs.nothing_) {
138 if (!rhs.nothing_) {
139 rhs.nothing_ = true;
141 // Move the value from rhs.
142 new (&storage_) T(std::move(reinterpret_cast<T&>(rhs.storage_)));
143 rhs.destroy();
149 Maybe<T>::Maybe(Maybe<U>&& rhs) : nothing_(rhs.nothing_) {
150 if (!rhs.nothing_) {
151 rhs.nothing_ = true;
153 // Move the value from rhs.
154 new (&storage_) T(std::move(reinterpret_cast<U&>(rhs.storage_)));
155 rhs.destroy();
160 inline Maybe<T>& Maybe<T>::operator=(const Maybe& rhs) {
162 return copy(rhs);
167 inline Maybe<T>& Maybe<T>::operator=(const Maybe<U>& rhs) {
168 return copy(rhs);
173 Maybe<T>& Maybe<T>::copy(const Maybe<U>& rhs) {
174 if (nothing_ && rhs.nothing_) {
177 } else if (!nothing_ && !rhs.nothing_) {
178 // We both are something, so assign rhs to us.
179 reinterpret_cast<T&>(storage_) = reinterpret_cast<const U&>(rhs.storage_);
181 // We are nothing but rhs is something.
182 nothing_ = rhs.nothing_;
184 // Copy the value from rhs.
185 new (&storage_) T(reinterpret_cast<const U&>(rhs.storage_));
187 // We are something but rhs is nothing, so destroy our value.
188 nothing_ = rhs.nothing_;
195 inline Maybe<T>& Maybe<T>::operator=(Maybe&& rhs) {
197 return move(std::forward<Maybe<T>>(rhs));
202 inline Maybe<T>& Maybe<T>::operator=(Maybe<U>&& rhs) {
203 return move(std::forward<Maybe<U>>(rhs));
208 Maybe<T>& Maybe<T>::move(Maybe<U>&& rhs) {
209 if (nothing_ && rhs.nothing_) {
212 } else if (!nothing_ && !rhs.nothing_) {
213 // We both are something, so move assign rhs to us.
214 rhs.nothing_ = true;
216 std::move(reinterpret_cast<U&>(rhs.storage_));
217 rhs.destroy();
219 // We are nothing but rhs is something.
221 rhs.nothing_ = true;
223 // Move the value from rhs.
224 new (&storage_) T(std::move(reinterpret_cast<U&>(rhs.storage_)));
225 rhs.destroy();
227 // We are something but rhs is nothing, so destroy our value.