Commit 99c72881 authored by Dan Melnic's avatar Dan Melnic Committed by Facebook GitHub Bot

Fix C++20 compile issues

Summary: Fix C++20 compile issues

Reviewed By: yfeldblum, mpark, ispeters

Differential Revision: D31938070

fbshipit-source-id: eed570b98685bfe5438a5d02f0417a40f495cb0f
parent fe92e62e
...@@ -31,20 +31,23 @@ namespace detail { ...@@ -31,20 +31,23 @@ namespace detail {
template <typename T> template <typename T>
class Queue { class Queue {
public: public:
Queue() {} constexpr Queue() noexcept {}
Queue(Queue&& other) : head_(std::exchange(other.head_, nullptr)) {} constexpr Queue(Queue&& other) noexcept
Queue& operator=(Queue&& other) { : head_(std::exchange(other.head_, nullptr)) {}
Queue& operator=(Queue&& other) noexcept {
clear(); clear();
std::swap(head_, other.head_); std::swap(head_, other.head_);
return *this; return *this;
} }
~Queue() { clear(); } ~Queue() { clear(); }
bool empty() const { return !head_; } bool empty() const noexcept { return !head_; }
T& front() { return head_->value; } T& front() noexcept { return head_->value; }
void pop() { std::unique_ptr<Node>(std::exchange(head_, head_->next)); } void pop() noexcept {
std::unique_ptr<Node>(std::exchange(head_, head_->next));
}
void clear() { void clear() {
while (!empty()) { while (!empty()) {
...@@ -61,8 +64,8 @@ class Queue { ...@@ -61,8 +64,8 @@ class Queue {
Node* next{nullptr}; Node* next{nullptr};
}; };
explicit Queue(Node* head) : head_(head) {} constexpr explicit Queue(Node* head) noexcept : head_(head) {}
static Queue fromReversed(Node* tail) { static Queue fromReversed(Node* tail) noexcept {
// Reverse a linked list. // Reverse a linked list.
Node* head{nullptr}; Node* head{nullptr};
while (tail) { while (tail) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment