Lines Matching refs:T

34 template <typename T>
67 Maybe(const T& value); // NOLINT(google-explicit-constructor)
72 Maybe(T&& value); // NOLINT(google-explicit-constructor)
84 T& value();
90 const T& value() const;
92 T value_or_default(const T& def) const;
108 typename std::aligned_storage<sizeof(T), alignof(T)>::type storage_;
111 template <typename T>
112 Maybe<T>::Maybe() : nothing_(true) {} in Maybe()
114 template <typename T>
115 Maybe<T>::~Maybe() { in ~Maybe()
121 template <typename T>
122 Maybe<T>::Maybe(const Maybe& rhs) : nothing_(rhs.nothing_) { in Maybe()
124 new (&storage_) T(reinterpret_cast<const T&>(rhs.storage_)); in Maybe()
128 template <typename T>
130 Maybe<T>::Maybe(const Maybe<U>& rhs) : nothing_(rhs.nothing_) { in Maybe()
132 new (&storage_) T(reinterpret_cast<const U&>(rhs.storage_)); in Maybe()
136 template <typename T>
137 Maybe<T>::Maybe(Maybe&& rhs) noexcept : nothing_(rhs.nothing_) { in Maybe()
142 new (&storage_) T(std::move(reinterpret_cast<T&>(rhs.storage_))); in Maybe()
147 template <typename T>
149 Maybe<T>::Maybe(Maybe<U>&& rhs) : nothing_(rhs.nothing_) { in Maybe()
154 new (&storage_) T(std::move(reinterpret_cast<U&>(rhs.storage_))); in Maybe()
159 template <typename T>
160 inline Maybe<T>& Maybe<T>::operator=(const Maybe& rhs) {
165 template <typename T>
167 inline Maybe<T>& Maybe<T>::operator=(const Maybe<U>& rhs) {
171 template <typename T>
173 Maybe<T>& Maybe<T>::copy(const Maybe<U>& rhs) { in copy()
179 reinterpret_cast<T&>(storage_) = reinterpret_cast<const U&>(rhs.storage_); in copy()
185 new (&storage_) T(reinterpret_cast<const U&>(rhs.storage_)); in copy()
194 template <typename T>
195 inline Maybe<T>& Maybe<T>::operator=(Maybe&& rhs) noexcept {
197 return move(std::forward<Maybe<T>>(rhs));
200 template <typename T>
202 inline Maybe<T>& Maybe<T>::operator=(Maybe<U>&& rhs) {
206 template <typename T>
208 Maybe<T>& Maybe<T>::move(Maybe<U>&& rhs) { in move()
215 reinterpret_cast<T&>(storage_) = in move()
224 new (&storage_) T(std::move(reinterpret_cast<U&>(rhs.storage_))); in move()
234 template <typename T>
235 Maybe<T>::Maybe(const T& value) : nothing_(false) { in Maybe()
236 new (&storage_) T(value); in Maybe()
239 template <typename T>
240 Maybe<T>::Maybe(T&& value) : nothing_(false) { in Maybe()
241 new (&storage_) T(std::forward<T>(value)); in Maybe()
244 template <typename T>
245 Maybe<T>::operator bool() const {
249 template <typename T>
250 T& Maybe<T>::value() { in value()
252 return reinterpret_cast<T&>(storage_); in value()
255 template <typename T>
256 const T& Maybe<T>::value() const { in value()
258 return reinterpret_cast<const T&>(storage_); in value()
261 template <typename T>
262 T Maybe<T>::value_or_default(const T& def) const { in value_or_default()
266 return reinterpret_cast<const T&>(storage_); in value_or_default()
269 template <typename T>
270 void Maybe<T>::destroy() { in destroy()
271 reinterpret_cast<T&>(storage_).~T(); in destroy()
274 template <typename T>
275 inline Maybe<typename std::remove_reference<T>::type> make_value(T&& value) { in make_value()
276 return Maybe<typename std::remove_reference<T>::type>(std::forward<T>(value)); in make_value()
279 template <typename T>
280 inline Maybe<T> make_nothing() { in make_nothing()
281 return Maybe<T>(); in make_nothing()
287 template <typename T, typename U>
288 typename std::enable_if<has_eq_op<T, U>::value, bool>::type operator==(const Maybe<T>& a,
298 template <typename T, typename U>
299 typename std::enable_if<has_eq_op<T, U>::value, bool>::type operator==(const Maybe<T>& a,
305 template <typename T, typename U>
306 typename std::enable_if<has_eq_op<T, U>::value, bool>::type operator!=(const Maybe<T>& a,
311 template <typename T, typename U>
312 typename std::enable_if<has_lt_op<T, U>::value, bool>::type operator<(const Maybe<T>& a,