proxygen
Nullable.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <folly/Poly.h>
20 #include <folly/poly/Regular.h>
21 
22 namespace folly {
23 namespace poly {
29 struct INullablePointer : PolyExtends<IEqualityComparable> {
30  template <class Base>
31  struct Interface : Base {
32  Interface() = default;
33  using Base::Base;
34 
35  /* implicit */ Interface(std::nullptr_t) : Base{} {
36  static_assert(
37  std::is_default_constructible<PolySelf<Base>>::value,
38  "Cannot initialize a non-default constructible Poly with nullptr");
39  }
40 
41  PolySelf<Base>& operator=(std::nullptr_t) {
42  static_assert(
43  std::is_default_constructible<PolySelf<Base>>::value,
44  "Cannot initialize a non-default constructible Poly with nullptr");
45  auto& self = static_cast<PolySelf<Base>&>(*this);
46  self = PolySelf<Base>();
47  return self;
48  }
49 
50  friend bool operator==(
51  std::nullptr_t,
52  PolySelf<Base> const& self) noexcept {
53  return poly_empty(self);
54  }
55  friend bool operator==(
56  PolySelf<Base> const& self,
57  std::nullptr_t) noexcept {
58  return poly_empty(self);
59  }
60  friend bool operator!=(
61  std::nullptr_t,
62  PolySelf<Base> const& self) noexcept {
63  return !poly_empty(self);
64  }
65  friend bool operator!=(
66  PolySelf<Base> const& self,
67  std::nullptr_t) noexcept {
68  return !poly_empty(self);
69  }
70  };
71 };
72 
79  template <class Base>
80  struct Interface : Base {
81  constexpr bool operator!() const noexcept {
82  return poly_empty(*this);
83  }
84  constexpr explicit operator bool() const noexcept {
85  return !!*this;
86  }
87  };
88 };
89 } // namespace poly
90 } // namespace folly
friend bool operator!=(std::nullptr_t, PolySelf< Base > const &self) noexcept
Definition: Nullable.h:60
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
requires E e noexcept(noexcept(s.error(std::move(e))))
friend bool operator!=(PolySelf< Base > const &self, std::nullptr_t) noexcept
Definition: Nullable.h:65
friend bool operator==(std::nullptr_t, PolySelf< Base > const &self) noexcept
Definition: Nullable.h:50
PolySelf< Base > & operator=(std::nullptr_t)
Definition: Nullable.h:41
friend bool operator==(PolySelf< Base > const &self, std::nullptr_t) noexcept
Definition: Nullable.h:55
AtomicCounter< T, DeterministicAtomic > Base
bool poly_empty(detail::PolyRoot< I > const &that) noexcept
Definition: Poly.h:383
constexpr bool operator!() const noexcept
Definition: Nullable.h:81
const
Definition: upload.py:398
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
decltype(Access::template self_< Node, Tfx >()) PolySelf
Definition: Poly.h:108