util: remove ndn::variant, use std::variant directly

Change-Id: I374095f0f391454f3340bbf36785ccbebea2773a
This commit is contained in:
Davide Pesavento committed 2023-03-12 13:46:02 -04:00
1 parent fcd3e44028
commit a2fbc35f12
5 files changed
+13 -2808

No files matched your search

-3
View File
@@ -18,9 +18,6 @@ ndn-cxx relies on third-party software, licensed under the following licenses:
- span-lite by Martin Moene is licensed under the
[Boost Software License 1.0](https://github.com/martinmoene/span-lite/blob/master/LICENSE.txt)
- variant-lite by Martin Moene is licensed under the
[Boost Software License 1.0](https://github.com/martinmoene/variant-lite/blob/master/LICENSE.txt)
- SQLite is in the [public domain](https://www.sqlite.org/copyright.html)
- The waf build system is licensed under the terms of the
File diff suppressed because it is too large. Load diff
+9 -9
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2022 Regents of the University of California.
* Copyright (c) 2013-2023 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -58,7 +58,7 @@ KeyLocator::wireEncode(EncodingImpl<TAG>& encoder) const
size_t totalLength = 0;
auto visitor = boost::hana::overload(
[] (monostate) {}, // nothing to encode, TLV-VALUE is empty
[] (std::monostate) {}, // nothing to encode, TLV-VALUE is empty
[&] (const Name& name) { totalLength += name.wireEncode(encoder); },
[&] (const Block& digest) { totalLength += prependBlock(encoder, digest); },
[] (uint32_t type) { NDN_THROW(Error("Unsupported KeyLocator type " + to_string(type))); });
@@ -126,7 +126,7 @@ KeyLocator::getType() const
case 2:
return tlv::KeyDigest;
case 3:
return get<uint32_t>(m_locator);
return std::get<uint32_t>(m_locator);
default:
NDN_CXX_UNREACHABLE;
}
@@ -135,7 +135,7 @@ KeyLocator::getType() const
KeyLocator&
KeyLocator::clear()
{
m_locator = monostate{};
m_locator = std::monostate{};
m_wire.reset();
return *this;
}
@@ -144,9 +144,9 @@ const Name&
KeyLocator::getName() const
{
try {
return get<Name>(m_locator);
return std::get<Name>(m_locator);
}
catch (const bad_variant_access&) {
catch (const std::bad_variant_access&) {
NDN_THROW(Error("KeyLocator does not contain a Name"));
}
}
@@ -163,9 +163,9 @@ const Block&
KeyLocator::getKeyDigest() const
{
try {
return get<Block>(m_locator);
return std::get<Block>(m_locator);
}
catch (const bad_variant_access&) {
catch (const std::bad_variant_access&) {
NDN_THROW(Error("KeyLocator does not contain a KeyDigest"));
}
}
@@ -194,7 +194,7 @@ std::ostream&
operator<<(std::ostream& os, const KeyLocator& keyLocator)
{
auto visitor = boost::hana::overload(
[&] (monostate) {
[&] (std::monostate) {
os << "None";
},
[&] (const Name& name) {
+4 -3
View File
@@ -23,7 +23,8 @@
#define NDN_CXX_KEY_LOCATOR_HPP
#include "ndn-cxx/name.hpp"
#include "ndn-cxx/util/variant.hpp"
#include <variant>
namespace ndn {
@@ -74,7 +75,7 @@ public: // attributes
[[nodiscard]] bool
empty() const
{
return holds_alternative<monostate>(m_locator);
return std::holds_alternative<std::monostate>(m_locator);
}
uint32_t
@@ -144,7 +145,7 @@ private:
// - Name is used when the nested TLV contains a name
// - Block is used when the nested TLV is a KeyDigest
// - in all other (unsupported) cases the nested TLV type is stored as uint32_t
variant<monostate, Name, Block, uint32_t> m_locator;
std::variant<std::monostate, Name, Block, uint32_t> m_locator;
mutable Block m_wire;
-51
View File
@@ -1,51 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2021 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
* ndn-cxx library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received copies of the GNU General Public License and GNU Lesser
* General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
* <http://www.gnu.org/licenses/>.
*
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
*/
#ifndef NDN_CXX_UTIL_VARIANT_HPP
#define NDN_CXX_UTIL_VARIANT_HPP
#define variant_CONFIG_SELECT_VARIANT variant_VARIANT_NONSTD
#define variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO 1
#define variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO 1
#include "ndn-cxx/detail/nonstd/variant-lite.hpp"
namespace ndn {
using ::nonstd::variant;
using ::nonstd::monostate;
using ::nonstd::bad_variant_access;
using ::nonstd::variant_npos;
using ::nonstd::variant_size;
using ::nonstd::variant_size_v;
using ::nonstd::variant_alternative;
using ::nonstd::variant_alternative_t;
using ::nonstd::visit;
using ::nonstd::holds_alternative;
using ::nonstd::get;
using ::nonstd::get_if;
using ::nonstd::in_place;
using ::nonstd::in_place_t;
} // namespace ndn
#endif // NDN_CXX_UTIL_VARIANT_HPP