mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
Replace wpi::optional with C++17 std::optional (#1732)
Keep wpi/optional.h as a shim with deprecated warnings.
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user