Prefer std::optional over boost:optional:

Some of the boost::optionals must remain for now.  Both
boost::beast and SOCI have interfaces that require
boost::optional.
This commit is contained in:
Scott Schurr
2020-11-13 15:09:18 -08:00
committed by Nik Bougalis
parent 85307b29d0
commit 3b33318dc8
241 changed files with 1293 additions and 1248 deletions

View File

@@ -186,7 +186,7 @@ public:
"Internal InnerObjectFormatsParsedJSON error. Bad JSON.");
}
STParsedJSONObject parsed("request", req);
bool const noObj = parsed.object == boost::none;
bool const noObj = !parsed.object.has_value();
if (noObj == test.expectFail)
{
pass();

View File

@@ -73,7 +73,7 @@ public:
}
bool
check(boost::optional<ECDSACanonicality> answer, std::string const& s)
check(std::optional<ECDSACanonicality> answer, std::string const& s)
{
return ecdsaCanonicality(makeSlice(sig(s))) == answer;
}
@@ -179,126 +179,126 @@ public:
"b6ba"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3005"
"0201FF"
"0200"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3006"
"020101"
"020202"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3006"
"020701"
"020102"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3006"
"020401"
"020102"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3006"
"020501"
"020102"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3006"
"020201"
"020102"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3006"
"020301"
"020202"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3006"
"020401"
"020202"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3047"
"0221005990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba"
"6105"
"022200002d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e56"
"6695ed"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3144"
"02205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61"
"05"
"02202d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695"
"ed"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3045"
"02205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61"
"05"
"02202d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695"
"ed"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"301F"
"01205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3045"
"02205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61"
"05"
"02202d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695"
"ed00"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3044"
"01205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61"
"05"
"02202d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695"
"ed"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3024"
"0200"
"02202d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695"
"ed"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3044"
"02208990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61"
"05"
"02202d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695"
"ed"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3045"
"0221005990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba"
"6105"
"02202d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695"
"ed"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3044"
"02205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61"
"05012"
"02d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695e"
"d"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3024"
"02205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61"
"05"
"0200"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3044"
"02205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61"
"05"
"0220fd5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695"
"ed"));
BEAST_EXPECT(check(
boost::none,
std::nullopt,
"3045"
"02205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61"
"05"

View File

@@ -415,7 +415,7 @@ public:
except<STObject::FieldErr>([&]() { st[sf3Outer]; });
BEAST_EXPECT(*st[~sf1Outer] == 1);
BEAST_EXPECT(*st[~sf2Outer] == 2);
BEAST_EXPECT(st[~sf3Outer] == boost::none);
BEAST_EXPECT(st[~sf3Outer] == std::nullopt);
BEAST_EXPECT(!!st[~sf1Outer]);
BEAST_EXPECT(!!st[~sf2Outer]);
BEAST_EXPECT(!st[~sf3Outer]);
@@ -457,14 +457,14 @@ public:
STObject st(sfGeneric);
unexcept([&]() { st[sf1Outer]; });
except([&]() { return st[sf1Outer] == 0; });
BEAST_EXPECT(st[~sf1Outer] == boost::none);
BEAST_EXPECT(st[~sf1Outer] == boost::optional<std::uint32_t>{});
BEAST_EXPECT(st[~sf1Outer] != boost::optional<std::uint32_t>(1));
BEAST_EXPECT(st[~sf1Outer] == std::nullopt);
BEAST_EXPECT(st[~sf1Outer] == std::optional<std::uint32_t>{});
BEAST_EXPECT(st[~sf1Outer] != std::optional<std::uint32_t>(1));
BEAST_EXPECT(!st[~sf1Outer]);
st[sf1Outer] = 2;
BEAST_EXPECT(st[sf1Outer] == 2);
BEAST_EXPECT(st[~sf1Outer] != boost::none);
BEAST_EXPECT(st[~sf1Outer] == boost::optional<std::uint32_t>(2));
BEAST_EXPECT(st[~sf1Outer] != std::nullopt);
BEAST_EXPECT(st[~sf1Outer] == std::optional<std::uint32_t>(2));
BEAST_EXPECT(!!st[~sf1Outer]);
st[sf1Outer] = 1;
BEAST_EXPECT(st[sf1Outer] == 1);
@@ -473,11 +473,11 @@ public:
st[sf1Outer] = 0;
BEAST_EXPECT(!st[sf1Outer]);
BEAST_EXPECT(!!st[~sf1Outer]);
st[~sf1Outer] = boost::none;
st[~sf1Outer] = std::nullopt;
BEAST_EXPECT(!st[~sf1Outer]);
BEAST_EXPECT(st[~sf1Outer] == boost::none);
BEAST_EXPECT(st[~sf1Outer] == boost::optional<std::uint32_t>{});
st[~sf1Outer] = boost::none;
BEAST_EXPECT(st[~sf1Outer] == std::nullopt);
BEAST_EXPECT(st[~sf1Outer] == std::optional<std::uint32_t>{});
st[~sf1Outer] = std::nullopt;
BEAST_EXPECT(!st[~sf1Outer]);
except([&]() { return st[sf1Outer] == 0; });
except([&]() { return *st[~sf1Outer]; });
@@ -502,16 +502,16 @@ public:
{
STObject st(sotOuter, sfGeneric);
BEAST_EXPECT(!!st[~sf1Outer]);
BEAST_EXPECT(st[~sf1Outer] != boost::none);
BEAST_EXPECT(st[~sf1Outer] != std::nullopt);
BEAST_EXPECT(st[sf1Outer] == 0);
BEAST_EXPECT(*st[~sf1Outer] == 0);
BEAST_EXPECT(!st[~sf2Outer]);
BEAST_EXPECT(st[~sf2Outer] == boost::none);
BEAST_EXPECT(st[~sf2Outer] == std::nullopt);
except([&]() { return st[sf2Outer] == 0; });
BEAST_EXPECT(!!st[~sf3Outer]);
BEAST_EXPECT(st[~sf3Outer] != boost::none);
BEAST_EXPECT(st[~sf3Outer] != std::nullopt);
BEAST_EXPECT(st[sf3Outer] == 0);
except([&]() { st[~sf1Outer] = boost::none; });
except([&]() { st[~sf1Outer] = std::nullopt; });
st[sf1Outer] = 1;
BEAST_EXPECT(st[sf1Outer] == 1);
BEAST_EXPECT(*st[~sf1Outer] == 1);
@@ -524,7 +524,7 @@ public:
BEAST_EXPECT(st[sf2Outer] == 2);
BEAST_EXPECT(*st[~sf2Outer] == 2);
BEAST_EXPECT(!!st[~sf2Outer]);
st[~sf2Outer] = boost::none;
st[~sf2Outer] = std::nullopt;
except([&]() { return *st[~sf2Outer]; });
BEAST_EXPECT(!st[~sf2Outer]);
st[sf3Outer] = 3;
@@ -539,13 +539,13 @@ public:
BEAST_EXPECT(st[sf3Outer] == 0);
BEAST_EXPECT(*st[~sf3Outer] == 0);
BEAST_EXPECT(!!st[~sf3Outer]);
except([&]() { st[~sf3Outer] = boost::none; });
except([&]() { st[~sf3Outer] = std::nullopt; });
BEAST_EXPECT(st[sf3Outer] == 0);
BEAST_EXPECT(*st[~sf3Outer] == 0);
BEAST_EXPECT(!!st[~sf3Outer]);
}
// coercion operator to boost::optional
// coercion operator to std::optional
{
STObject st(sfGeneric);
@@ -553,7 +553,7 @@ public:
static_assert(
std::is_same<
std::decay_t<decltype(v)>,
boost::optional<std::uint32_t>>::value,
std::optional<std::uint32_t>>::value,
"");
}
@@ -577,7 +577,7 @@ public:
st[sf4] = std::move(b);
BEAST_EXPECT(b.empty());
BEAST_EXPECT(Slice(st[sf4]).size() == 1);
st[~sf4] = boost::none;
st[~sf4] = std::nullopt;
BEAST_EXPECT(!~st[~sf4]);
b = Buffer{2};
st[sf4] = Slice(b);
@@ -596,7 +596,7 @@ public:
st[sf5] = std::move(b);
BEAST_EXPECT(b.empty());
BEAST_EXPECT(Slice(st[sf5]).size() == 1);
st[~sf4] = boost::none;
st[~sf4] = std::nullopt;
BEAST_EXPECT(!~st[~sf4]);
}
}
@@ -610,7 +610,7 @@ public:
generateKeyPair(KeyType::secp256k1, generateSeed("masterpassphrase"));
st[sf5] = kp.first;
BEAST_EXPECT(st[sf5] != PublicKey{});
st[~sf5] = boost::none;
st[~sf5] = std::nullopt;
#if 0
pk = st[sf5];
BEAST_EXPECT(pk.size() == 0);
@@ -663,7 +663,7 @@ public:
st[sf2] = v;
BEAST_EXPECT(cst[sf2].size() == 1);
BEAST_EXPECT(cst[sf2][0] == uint256{1});
st[~sf2] = boost::none;
st[~sf2] = std::nullopt;
BEAST_EXPECT(!st[~sf2]);
st[sf3] = v;
BEAST_EXPECT(cst[sf3].size() == 1);