Replace wpi::optional with C++17 std::optional (#1732)

Keep wpi/optional.h as a shim with deprecated warnings.
This commit is contained in:
Peter Johnson
2019-06-29 11:20:22 -07:00
committed by GitHub
parent 0fbb0d989e
commit 4b1b92bb74
11 changed files with 52 additions and 2490 deletions

View File

@@ -14,7 +14,6 @@
#ifndef WPIUTIL_WPI_SMALLSET_H
#define WPIUTIL_WPI_SMALLSET_H
#include "wpi/optional.h"
#include "wpi/SmallPtrSet.h"
#include "wpi/SmallVector.h"
#include "wpi/Compiler.h"
@@ -22,6 +21,7 @@
#include "wpi/type_traits.h"
#include <cstddef>
#include <functional>
#include <optional>
#include <set>
#include <type_traits>
#include <utility>
@@ -178,16 +178,16 @@ public:
/// concept.
// FIXME: Add iterators that abstract over the small and large form, and then
// return those here.
std::pair<nullopt_t, bool> insert(const T &V) {
std::pair<std::nullopt_t, bool> insert(const T &V) {
if (!isSmall())
return std::make_pair(nullopt, Set.insert(V).second);
return std::make_pair(std::nullopt, Set.insert(V).second);
VIterator I = vfind(V);
if (I != Vector.end()) // Don't reinsert if it already exists.
return std::make_pair(nullopt, false);
return std::make_pair(std::nullopt, false);
if (Vector.size() < N) {
Vector.push_back(V);
return std::make_pair(nullopt, true);
return std::make_pair(std::nullopt, true);
}
// Otherwise, grow from vector to set.
@@ -196,7 +196,7 @@ public:
Vector.pop_back();
}
Set.insert(V);
return std::make_pair(nullopt, true);
return std::make_pair(std::nullopt, true);
}
template <typename IterT>