build: switch to C++17
Change-Id: I92039300ce845de0312dceccb94c128229ed60c4
This commit is contained in:
1 parent
762548b15e
commit
fcd3e44028
38 files changed
+116
-235
No files matched your search
@@ -16,7 +16,7 @@ if [[ $ID_LIKE == *fedora* ]]; then
|
||||
fi
|
||||
|
||||
CXX=${CXX:-g++}
|
||||
STD=-std=c++14
|
||||
STD=-std=c++17
|
||||
CXXFLAGS="-O2 -Wall -Wno-unneeded-internal-declaration -Wno-unused-const-variable $(pkg-config --cflags libndn-cxx $PCFILE)"
|
||||
INCLUDEDIR="$(pkg-config --variable=includedir $PCFILE)"/$PROJ
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ class GccBasicFlags(CompilerFlags):
|
||||
"""
|
||||
def getGeneralFlags(self, conf):
|
||||
flags = super(GccBasicFlags, self).getGeneralFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-std=c++14']
|
||||
flags['CXXFLAGS'] += ['-std=c++17']
|
||||
if Utils.unversioned_sys_platform() != 'darwin':
|
||||
flags['LINKFLAGS'] += ['-fuse-ld=lld']
|
||||
return flags
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
|
||||
[](https://github.com/named-data/ndn-cxx/actions/workflows/ci.yml)
|
||||
[](https://github.com/named-data/ndn-cxx/actions/workflows/docs.yml)
|
||||

|
||||

|
||||

|
||||
|
||||
**ndn-cxx** is a C++14 library implementing Named Data Networking (NDN) primitives
|
||||
**ndn-cxx** is a C++17 library implementing Named Data Networking (NDN) primitives
|
||||
that can be used to write various NDN applications. The library is currently being
|
||||
used by the following projects:
|
||||
|
||||
|
||||
+7
-7
@@ -180,7 +180,7 @@ extended it to C++.
|
||||
switch (condition) {
|
||||
case ABC: // 2 space indent
|
||||
statements; // 4 space indent
|
||||
NDN_CXX_FALLTHROUGH;
|
||||
[[fallthrough]];
|
||||
|
||||
case DEF:
|
||||
statements;
|
||||
@@ -211,7 +211,7 @@ extended it to C++.
|
||||
// Correct style
|
||||
case A1: {
|
||||
statements;
|
||||
NDN_CXX_FALLTHROUGH;
|
||||
[[fallthrough]];
|
||||
}
|
||||
|
||||
// Incorrect style: braces should cover the entire case block
|
||||
@@ -232,7 +232,7 @@ extended it to C++.
|
||||
switch (condition) {
|
||||
case ABC: // no indent
|
||||
statements; // 2 space indent
|
||||
NDN_CXX_FALLTHROUGH;
|
||||
[[fallthrough]];
|
||||
|
||||
case DEF:
|
||||
statements;
|
||||
@@ -243,11 +243,11 @@ extended it to C++.
|
||||
break;
|
||||
}
|
||||
|
||||
The ``NDN_CXX_FALLTHROUGH`` annotation must be included whenever there is
|
||||
a case without a break statement. Leaving the break out is a common error,
|
||||
The ``[[fallthrough]]`` annotation must be included whenever there is a
|
||||
case without a break statement. Leaving the break out is a common error,
|
||||
and it must be made clear that it is intentional when it is not there.
|
||||
Moreover, modern compilers will warn when a case that falls through is not
|
||||
explicitly annotated.
|
||||
Moreover, modern compilers will warn when a case that falls through is
|
||||
not explicitly annotated.
|
||||
|
||||
1.11. A ``try-catch`` statement should have the following form:
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ ndn-cxx: NDN C++ library with eXperimental eXtensions
|
||||
release-notes
|
||||
releases
|
||||
|
||||
**ndn-cxx** is a C++14 library implementing Named Data Networking (NDN) primitives
|
||||
**ndn-cxx** is a C++17 library implementing Named Data Networking (NDN) primitives
|
||||
that can be used to write various NDN applications. The library is currently being
|
||||
used by the following projects:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2013-2021 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).
|
||||
*
|
||||
@@ -30,9 +30,9 @@
|
||||
|
||||
#include "ndn-cxx/detail/config.hpp"
|
||||
|
||||
// require C++14
|
||||
#if __cplusplus < 201402L
|
||||
#error "ndn-cxx applications must be compiled using the C++14 standard (-std=c++14)"
|
||||
// require C++17
|
||||
#if __cplusplus < 201703L
|
||||
#error "ndn-cxx applications must be compiled using the C++17 standard (-std=c++17)"
|
||||
#endif
|
||||
|
||||
// ndn-cxx specific macros declared in this and other headers must have NDN_CXX_ prefix
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -162,7 +162,7 @@ public: // construction, assignment
|
||||
* @return `true` and the parsed Block if parsing succeeds; otherwise `false` and an invalid Block
|
||||
* @note This function does not throw upon decoding failure.
|
||||
*/
|
||||
NDN_CXX_NODISCARD static std::tuple<bool, Block>
|
||||
[[nodiscard]] static std::tuple<bool, Block>
|
||||
fromBuffer(ConstBufferPtr buffer, size_t offset = 0);
|
||||
|
||||
/** @brief Try to parse Block from a byte range
|
||||
@@ -172,7 +172,7 @@ public: // construction, assignment
|
||||
* @note This overload copies the TLV element octets to an internal buffer.
|
||||
* @note This function does not throw upon decoding failure.
|
||||
*/
|
||||
NDN_CXX_NODISCARD static std::tuple<bool, Block>
|
||||
[[nodiscard]] static std::tuple<bool, Block>
|
||||
fromBuffer(span<const uint8_t> buffer);
|
||||
|
||||
/** @brief Parse Block from an input stream
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -176,7 +176,7 @@ isCriticalType(uint32_t type) noexcept
|
||||
* @return true if number was successfully read from input, false otherwise
|
||||
*/
|
||||
template<typename Iterator>
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
readVarNumber(Iterator& begin, Iterator end, uint64_t& number) noexcept;
|
||||
|
||||
/**
|
||||
@@ -193,7 +193,7 @@ readVarNumber(Iterator& begin, Iterator end, uint64_t& number) noexcept;
|
||||
* the TLV-TYPE is zero or larger than 2^32-1 (maximum allowed by the packet format).
|
||||
*/
|
||||
template<typename Iterator>
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
readType(Iterator& begin, Iterator end, uint32_t& type) noexcept;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -109,7 +109,7 @@ public: // consumer
|
||||
void
|
||||
asyncRemovePendingInterest(detail::RecordId id)
|
||||
{
|
||||
m_face.getIoService().post([id, w = weak_ptr<Impl>{shared_from_this()}] { // use weak_from_this() in C++17
|
||||
m_face.getIoService().post([id, w = weak_from_this()] {
|
||||
auto impl = w.lock();
|
||||
if (impl != nullptr) {
|
||||
impl->m_pendingInterestTable.erase(id);
|
||||
@@ -195,7 +195,7 @@ public: // producer
|
||||
void
|
||||
asyncUnsetInterestFilter(detail::RecordId id)
|
||||
{
|
||||
m_face.getIoService().post([id, w = weak_ptr<Impl>{shared_from_this()}] { // use weak_from_this() in C++17
|
||||
m_face.getIoService().post([id, w = weak_from_this()] {
|
||||
auto impl = w.lock();
|
||||
if (impl != nullptr) {
|
||||
impl->unsetInterestFilter(id);
|
||||
@@ -292,7 +292,7 @@ public: // prefix registration
|
||||
const UnregisterPrefixSuccessCallback& onSuccess,
|
||||
const UnregisterPrefixFailureCallback& onFailure)
|
||||
{
|
||||
m_face.getIoService().post([=, w = weak_ptr<Impl>{shared_from_this()}] { // use weak_from_this() in C++17
|
||||
m_face.getIoService().post([=, w = weak_from_this()] {
|
||||
auto impl = w.lock();
|
||||
if (impl != nullptr) {
|
||||
impl->unregisterPrefix(id, onSuccess, onFailure);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2013-2021 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).
|
||||
*
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
});
|
||||
}
|
||||
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
empty() const noexcept
|
||||
{
|
||||
return m_container.empty();
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
/**
|
||||
* \brief Get whether Interest loopback is allowed.
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
allowsLoopback() const noexcept
|
||||
{
|
||||
return m_allowsLoopback;
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -758,8 +758,7 @@ operator<<(std::ostream& os, const Interest& interest)
|
||||
auto printOne = [&] (const auto&... args) {
|
||||
os << delim;
|
||||
delim = '&';
|
||||
using expand = int[];
|
||||
(void)expand{(os << args, 0)...}; // use a fold expression when we switch to C++17
|
||||
(os << ... << args);
|
||||
};
|
||||
|
||||
if (interest.getCanBePrefix()) {
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -464,7 +464,7 @@ private:
|
||||
Interest&
|
||||
setSignatureValueInternal(Block sigValue);
|
||||
|
||||
NDN_CXX_NODISCARD shared_ptr<Buffer>
|
||||
[[nodiscard]] shared_ptr<Buffer>
|
||||
computeParametersDigest() const;
|
||||
|
||||
/** @brief Append a ParametersSha256DigestComponent to the Interest's name
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -71,7 +71,7 @@ public: // encode and decode
|
||||
wireDecode(const Block& wire);
|
||||
|
||||
public: // attributes
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
empty() const
|
||||
{
|
||||
return holds_alternative<monostate>(m_locator);
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
* \retval true packet has no field
|
||||
* \retval false packet has one or more fields
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
empty() const
|
||||
{
|
||||
return m_wire.elements_size() == 0;
|
||||
@@ -73,7 +73,7 @@ public: // field access
|
||||
* \details This is equivalent to count() > 0
|
||||
*/
|
||||
template<typename FIELD>
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
has() const
|
||||
{
|
||||
return count<FIELD>() > 0;
|
||||
@@ -83,7 +83,7 @@ public: // field access
|
||||
* \brief Returns the number of occurrences of \c FIELD.
|
||||
*/
|
||||
template<typename FIELD>
|
||||
NDN_CXX_NODISCARD size_t
|
||||
[[nodiscard]] size_t
|
||||
count() const
|
||||
{
|
||||
return std::count_if(m_wire.elements_begin(), m_wire.elements_end(),
|
||||
@@ -115,7 +115,7 @@ public: // field access
|
||||
* \brief Returns the values of all occurrences of \c FIELD.
|
||||
*/
|
||||
template<typename FIELD>
|
||||
NDN_CXX_NODISCARD std::vector<typename FIELD::ValueType>
|
||||
[[nodiscard]] std::vector<typename FIELD::ValueType>
|
||||
list() const
|
||||
{
|
||||
std::vector<typename FIELD::ValueType> output;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2013-2021 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).
|
||||
*
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
*
|
||||
* @throw tlv::Error @p discoveryInterestName is not valid
|
||||
*/
|
||||
NDN_CXX_NODISCARD Data
|
||||
[[nodiscard]] Data
|
||||
makeData(Name discoveryInterestName,
|
||||
KeyChain& keyChain,
|
||||
const ndn::security::SigningInfo& si = security::SigningInfo(),
|
||||
@@ -123,7 +123,7 @@ public: // static methods
|
||||
*
|
||||
* @param name prefix of data collection
|
||||
*/
|
||||
NDN_CXX_NODISCARD static Interest
|
||||
[[nodiscard]] static Interest
|
||||
makeDiscoveryInterest(Name name);
|
||||
|
||||
private:
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -543,7 +543,7 @@ public: // commonly used TLV-TYPEs
|
||||
}
|
||||
|
||||
public: // comparison
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
empty() const noexcept
|
||||
{
|
||||
return value_size() == 0;
|
||||
|
||||
+2
-2
@@ -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).
|
||||
*
|
||||
@@ -142,7 +142,7 @@ public: // access
|
||||
/**
|
||||
* @brief Checks if the name is empty, i.e., has no components.
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
empty() const noexcept
|
||||
{
|
||||
return m_wire.elements().empty();
|
||||
|
||||
@@ -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,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
FaceUri(const char* uri);
|
||||
|
||||
/// Exception-safe parsing.
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
parse(const std::string& uri);
|
||||
|
||||
public: // scheme-specific construction
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2013-2021 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).
|
||||
*
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
* @warning May return incomplete results if called before the
|
||||
* #onEnumerationCompleted signal has been emitted.
|
||||
*/
|
||||
NDN_CXX_NODISCARD std::vector<shared_ptr<const NetworkInterface>>
|
||||
[[nodiscard]] std::vector<shared_ptr<const NetworkInterface>>
|
||||
listNetworkInterfaces() const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -31,10 +31,10 @@ namespace ndn {
|
||||
namespace security {
|
||||
namespace detail {
|
||||
|
||||
NDN_CXX_NODISCARD const EVP_MD*
|
||||
[[nodiscard]] const EVP_MD*
|
||||
digestAlgorithmToEvpMd(DigestAlgorithm algo);
|
||||
|
||||
NDN_CXX_NODISCARD int
|
||||
[[nodiscard]] int
|
||||
getEvpPkeyType(const EVP_PKEY* key);
|
||||
|
||||
class EvpMdCtx : noncopyable
|
||||
@@ -86,10 +86,10 @@ public:
|
||||
return m_bio;
|
||||
}
|
||||
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
read(span<uint8_t> buf) const noexcept;
|
||||
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
write(span<const uint8_t> buf) noexcept;
|
||||
|
||||
private:
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -114,13 +114,13 @@ KeyChain::getDefaultKeyParams()
|
||||
class KeyChain::Locator
|
||||
{
|
||||
public:
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
empty() const
|
||||
{
|
||||
return scheme.empty();
|
||||
}
|
||||
|
||||
NDN_CXX_NODISCARD std::string
|
||||
[[nodiscard]] std::string
|
||||
canonical() const
|
||||
{
|
||||
return scheme + ':' + location;
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
/**
|
||||
* @brief Check whether the container is empty.
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
empty() const noexcept
|
||||
{
|
||||
return m_certNames.empty();
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
/**
|
||||
* @brief Check whether the container is empty.
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
empty() const noexcept
|
||||
{
|
||||
return m_identityNames.empty();
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
/**
|
||||
* @brief Check whether the container is empty.
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
empty() const noexcept
|
||||
{
|
||||
return m_keyNames.empty();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2013-2021 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).
|
||||
*
|
||||
@@ -155,7 +155,7 @@ public: // key management
|
||||
*
|
||||
* @return True if the TPM was unlocked.
|
||||
*/
|
||||
NDN_CXX_NODISCARD virtual bool
|
||||
[[nodiscard]] virtual bool
|
||||
unlockTpm(const char* pw, size_t pwLen) const;
|
||||
|
||||
protected: // helper methods
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
* @retval false the signature is not valid
|
||||
* @retval indeterminate the key does not exist
|
||||
*/
|
||||
NDN_CXX_NODISCARD boost::logic::tribool
|
||||
[[nodiscard]] boost::logic::tribool
|
||||
verify(const InputBuffers& bufs, span<const uint8_t> sig, const Name& keyName,
|
||||
DigestAlgorithm digestAlgorithm) const;
|
||||
|
||||
@@ -156,7 +156,7 @@ public: // Management
|
||||
* @param password The password to unlock the TPM.
|
||||
* @param passwordLength The password size.
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
unlockTpm(const char* password, size_t passwordLength) const;
|
||||
|
||||
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE: // operations accessible only by KeyChain
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -51,21 +51,21 @@ class Certificate;
|
||||
/**
|
||||
* @brief Verify @p blobs using @p key against @p sig.
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
verifySignature(const InputBuffers& blobs, span<const uint8_t> sig, const transform::PublicKey& key);
|
||||
|
||||
/**
|
||||
* @brief Verify @p blobs using @p key against @p sig.
|
||||
* @note @p key must be a public key in PKCS #8 format.
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
verifySignature(const InputBuffers& blobs, span<const uint8_t> sig, span<const uint8_t> key);
|
||||
|
||||
/**
|
||||
* @brief Verify @p data using @p key.
|
||||
* @note @p key must be a public key in PKCS #8 format.
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
verifySignature(const Data& data, span<const uint8_t> key);
|
||||
|
||||
/**
|
||||
@@ -73,33 +73,33 @@ verifySignature(const Data& data, span<const uint8_t> key);
|
||||
* @note @p key must be a public key in PKCS #8 format.
|
||||
* @note This method verifies only signature of the signed interest.
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
verifySignature(const Interest& interest, span<const uint8_t> key);
|
||||
|
||||
/**
|
||||
* @brief Verify @p data using @p key.
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
verifySignature(const Data& data, const transform::PublicKey& key);
|
||||
|
||||
/**
|
||||
* @brief Verify @p interest using @p key.
|
||||
* @note This method verifies only signature of the signed interest.
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
verifySignature(const Interest& interest, const transform::PublicKey& key);
|
||||
|
||||
/**
|
||||
* @brief Verify @p data using @p key.
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
verifySignature(const Data& data, const pib::Key& key);
|
||||
|
||||
/**
|
||||
* @brief Verify @p interest using @p key.
|
||||
* @note This method verifies only signature of the signed interest.
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
verifySignature(const Interest& interest, const pib::Key& key);
|
||||
|
||||
/**
|
||||
@@ -107,7 +107,7 @@ verifySignature(const Interest& interest, const pib::Key& key);
|
||||
*
|
||||
* If @p cert is nullopt, @p data assumed to be self-verifiable (with digest or attributes)
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
verifySignature(const Data& data, const optional<Certificate>& cert);
|
||||
|
||||
/**
|
||||
@@ -116,13 +116,13 @@ verifySignature(const Data& data, const optional<Certificate>& cert);
|
||||
*
|
||||
* If @p cert is nullptr, @p interest assumed to be self-verifiable (with digest or attributes)
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
verifySignature(const Interest& interest, const optional<Certificate>& cert);
|
||||
|
||||
/**
|
||||
* @brief Verify @p data using @p tpm and @p keyName with the @p digestAlgorithm.
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
verifySignature(const Data& data, const tpm::Tpm& tpm, const Name& keyName,
|
||||
DigestAlgorithm digestAlgorithm);
|
||||
|
||||
@@ -130,7 +130,7 @@ verifySignature(const Data& data, const tpm::Tpm& tpm, const Name& keyName,
|
||||
* @brief Verify @p interest using @p tpm and @p keyName with the @p digestAlgorithm.
|
||||
* @note This method verifies only signature of the signed interest.
|
||||
*/
|
||||
NDN_CXX_NODISCARD bool
|
||||
[[nodiscard]] bool
|
||||
verifySignature(const Interest& interest, const tpm::Tpm& tpm, const Name& keyName,
|
||||
DigestAlgorithm digestAlgorithm);
|
||||
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -28,50 +28,12 @@
|
||||
#include <boost/predef/compiler/gcc.h>
|
||||
#include <boost/predef/compiler/visualc.h>
|
||||
|
||||
#ifdef __has_cpp_attribute
|
||||
# define NDN_CXX_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
|
||||
#else
|
||||
# define NDN_CXX_HAS_CPP_ATTRIBUTE(x) 0
|
||||
#endif
|
||||
|
||||
#ifdef __has_include
|
||||
# define NDN_CXX_HAS_INCLUDE(x) __has_include(x)
|
||||
#else
|
||||
# define NDN_CXX_HAS_INCLUDE(x) 0
|
||||
#endif
|
||||
|
||||
//
|
||||
// https://wg21.link/P0188
|
||||
// [[fallthrough]] attribute (C++17)
|
||||
//
|
||||
#if (__cplusplus > 201402L) && NDN_CXX_HAS_CPP_ATTRIBUTE(fallthrough)
|
||||
# define NDN_CXX_FALLTHROUGH [[fallthrough]]
|
||||
#elif NDN_CXX_HAS_CPP_ATTRIBUTE(clang::fallthrough)
|
||||
# define NDN_CXX_FALLTHROUGH [[clang::fallthrough]]
|
||||
#elif NDN_CXX_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
|
||||
# define NDN_CXX_FALLTHROUGH [[gnu::fallthrough]]
|
||||
#elif BOOST_COMP_GNUC >= BOOST_VERSION_NUMBER(7,0,0)
|
||||
# define NDN_CXX_FALLTHROUGH __attribute__((fallthrough))
|
||||
#else
|
||||
# define NDN_CXX_FALLTHROUGH ((void)0)
|
||||
#endif
|
||||
|
||||
//
|
||||
// https://wg21.link/P0189
|
||||
// [[nodiscard]] attribute (C++17)
|
||||
//
|
||||
#if (__cplusplus > 201402L) && NDN_CXX_HAS_CPP_ATTRIBUTE(nodiscard)
|
||||
# define NDN_CXX_NODISCARD [[nodiscard]]
|
||||
#elif NDN_CXX_HAS_CPP_ATTRIBUTE(gnu::warn_unused_result)
|
||||
# define NDN_CXX_NODISCARD [[gnu::warn_unused_result]]
|
||||
#else
|
||||
# define NDN_CXX_NODISCARD
|
||||
#endif
|
||||
|
||||
#ifndef NDN_CXX_HAVE_STD_TO_STRING
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#endif
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace ndn {
|
||||
|
||||
//
|
||||
@@ -89,30 +51,6 @@ to_string(const T& val)
|
||||
}
|
||||
#endif // NDN_CXX_HAVE_STD_TO_STRING
|
||||
|
||||
//
|
||||
// https://wg21.link/P0025
|
||||
// std::clamp() (C++17)
|
||||
//
|
||||
#if __cpp_lib_clamp >= 201603L
|
||||
using std::clamp;
|
||||
#else
|
||||
template<typename T, typename Compare>
|
||||
constexpr const T&
|
||||
clamp(const T& v, const T& lo, const T& hi, Compare comp)
|
||||
{
|
||||
BOOST_ASSERT(!comp(hi, lo));
|
||||
return comp(v, lo) ? lo : comp(hi, v) ? hi : v;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr const T&
|
||||
clamp(const T& v, const T& lo, const T& hi)
|
||||
{
|
||||
BOOST_ASSERT(!(hi < lo));
|
||||
return (v < lo) ? lo : (hi < v) ? hi : v;
|
||||
}
|
||||
#endif // __cpp_lib_clamp
|
||||
|
||||
//
|
||||
// https://wg21.link/P1682
|
||||
// std::to_underlying() (C++23)
|
||||
@@ -121,7 +59,7 @@ clamp(const T& v, const T& lo, const T& hi)
|
||||
using std::to_underlying;
|
||||
#else
|
||||
template<typename T>
|
||||
NDN_CXX_NODISCARD constexpr std::underlying_type_t<T>
|
||||
[[nodiscard]] constexpr std::underlying_type_t<T>
|
||||
to_underlying(T val) noexcept
|
||||
{
|
||||
// instantiating underlying_type with a non-enum type is UB before C++20
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
/**
|
||||
* \brief Get list of all registered logger names.
|
||||
*/
|
||||
NDN_CXX_NODISCARD static std::set<std::string>
|
||||
[[nodiscard]] static std::set<std::string>
|
||||
getLoggerNames();
|
||||
|
||||
/** \brief Set severity level.
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
/**
|
||||
* \brief Create stream log destination using default formatting.
|
||||
*/
|
||||
NDN_CXX_NODISCARD static boost::shared_ptr<boost::log::sinks::sink>
|
||||
[[nodiscard]] static boost::shared_ptr<boost::log::sinks::sink>
|
||||
makeDefaultStreamDestination(shared_ptr<std::ostream> os, bool wantAutoFlush = true);
|
||||
|
||||
private:
|
||||
@@ -130,7 +130,7 @@ private:
|
||||
void
|
||||
registerLoggerNameImpl(std::string name);
|
||||
|
||||
NDN_CXX_NODISCARD std::set<std::string>
|
||||
[[nodiscard]] std::set<std::string>
|
||||
getLoggerNamesImpl() const;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2013-2021 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).
|
||||
*
|
||||
@@ -19,17 +19,18 @@
|
||||
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Backport of ostream_joiner from the Library Fundamentals v2 TS
|
||||
/**
|
||||
* \file
|
||||
* \brief Backport of `ostream_joiner` from the Library Fundamentals v2 TS
|
||||
* \sa https://en.cppreference.com/w/cpp/experimental/ostream_joiner
|
||||
*/
|
||||
|
||||
#ifndef NDN_CXX_UTIL_OSTREAM_JOINER_HPP
|
||||
#define NDN_CXX_UTIL_OSTREAM_JOINER_HPP
|
||||
|
||||
#include "ndn-cxx/util/backports.hpp"
|
||||
#include "ndn-cxx/detail/common.hpp"
|
||||
|
||||
#if NDN_CXX_HAS_INCLUDE(<experimental/iterator>)
|
||||
#if __has_include(<experimental/iterator>)
|
||||
# include <experimental/iterator>
|
||||
# if __cpp_lib_experimental_ostream_joiner >= 201411
|
||||
# define NDN_CXX_HAVE_EXPERIMENTAL_OSTREAM_JOINER
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2013-2019 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).
|
||||
*
|
||||
@@ -206,7 +206,7 @@ RegexTopMatcher::convertSpecialChar(const std::string& str)
|
||||
case '^':
|
||||
case '$':
|
||||
newStr.push_back('\\');
|
||||
NDN_CXX_FALLTHROUGH;
|
||||
[[fallthrough]];
|
||||
default:
|
||||
newStr.push_back(c);
|
||||
break;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (C) 2016-2019, Arizona Board of Regents.
|
||||
* Copyright (C) 2016-2023, Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
*
|
||||
@@ -59,14 +59,14 @@ RttEstimator::addMeasurement(time::nanoseconds rtt, size_t nExpectedSamples)
|
||||
beta * time::abs(m_sRtt - rtt));
|
||||
m_sRtt = time::duration_cast<time::nanoseconds>((1 - alpha) * m_sRtt + alpha * rtt);
|
||||
}
|
||||
m_rto = clamp(m_sRtt + m_options->k * m_rttVar,
|
||||
m_rto = std::clamp(m_sRtt + m_options->k * m_rttVar,
|
||||
m_options->minRto, m_options->maxRto);
|
||||
}
|
||||
|
||||
void
|
||||
RttEstimator::backoffRto()
|
||||
{
|
||||
m_rto = clamp(m_rto * m_options->rtoBackoffMultiplier,
|
||||
m_rto = std::clamp(m_rto * m_options->rtoBackoffMultiplier,
|
||||
m_options->minRto, m_options->maxRto);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2013-2020 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).
|
||||
*
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
NDN_CXX_NODISCARD time::nanoseconds
|
||||
[[nodiscard]] time::nanoseconds
|
||||
expiresFromNow() const
|
||||
{
|
||||
return std::max(expireTime - time::steady_clock::now(), 0_ns);
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
* @param contentType The `ContentType` of created Data packets.
|
||||
* @note A minimum of one Data packet is always returned, even if @p buffer is empty.
|
||||
*/
|
||||
NDN_CXX_NODISCARD std::vector<std::shared_ptr<Data>>
|
||||
[[nodiscard]] std::vector<std::shared_ptr<Data>>
|
||||
segment(span<const uint8_t> buffer,
|
||||
const Name& dataName,
|
||||
size_t maxSegmentSize,
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
* @param contentType The `ContentType` of created Data packets.
|
||||
* @note A minimum of one Data packet is always returned, even if @p input is empty.
|
||||
*/
|
||||
NDN_CXX_NODISCARD std::vector<std::shared_ptr<Data>>
|
||||
[[nodiscard]] std::vector<std::shared_ptr<Data>>
|
||||
segment(std::istream& input,
|
||||
const Name& dataName,
|
||||
size_t maxSegmentSize,
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -99,7 +99,7 @@ private:
|
||||
* Each octet of input is always converted to two hex characters (e.g., "00" for octet==0).
|
||||
* The output string is a continuous sequence of hex characters without any whitespace separators.
|
||||
*/
|
||||
NDN_CXX_NODISCARD std::string
|
||||
[[nodiscard]] std::string
|
||||
toHex(span<const uint8_t> buffer, bool wantUpperCase = true);
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ fromHex(const std::string& hexString);
|
||||
/**
|
||||
* @brief Convert (the least significant nibble of) @p n to the corresponding hex character.
|
||||
*/
|
||||
NDN_CXX_NODISCARD constexpr char
|
||||
[[nodiscard]] constexpr char
|
||||
toHexChar(unsigned int n, bool wantUpperCase = true) noexcept
|
||||
{
|
||||
return wantUpperCase ?
|
||||
@@ -125,7 +125,7 @@ toHexChar(unsigned int n, bool wantUpperCase = true) noexcept
|
||||
/**
|
||||
* @brief Convert the hex character @p c to an integer in [0, 15], or -1 if it's not a hex character.
|
||||
*/
|
||||
NDN_CXX_NODISCARD constexpr int
|
||||
[[nodiscard]] constexpr int
|
||||
fromHexChar(char c) noexcept
|
||||
{
|
||||
return (c >= '0' && c <= '9') ? int(c - '0') :
|
||||
@@ -151,7 +151,7 @@ fromHexChar(char c) noexcept
|
||||
*
|
||||
* @see RFC 3986 section 2
|
||||
*/
|
||||
NDN_CXX_NODISCARD std::string
|
||||
[[nodiscard]] std::string
|
||||
escape(const std::string& str);
|
||||
|
||||
void
|
||||
@@ -171,7 +171,7 @@ escape(std::ostream& os, const char* str, size_t len);
|
||||
*
|
||||
* @see RFC 3986 section 2
|
||||
*/
|
||||
NDN_CXX_NODISCARD std::string
|
||||
[[nodiscard]] std::string
|
||||
unescape(const std::string& str);
|
||||
|
||||
void
|
||||
|
||||
@@ -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).
|
||||
*
|
||||
@@ -35,10 +35,10 @@ class PibDataFixture
|
||||
public:
|
||||
PibDataFixture();
|
||||
|
||||
NDN_CXX_NODISCARD static shared_ptr<PibImpl>
|
||||
[[nodiscard]] static shared_ptr<PibImpl>
|
||||
makePibWithIdentity(const Name& idName);
|
||||
|
||||
NDN_CXX_NODISCARD static shared_ptr<PibImpl>
|
||||
[[nodiscard]] static shared_ptr<PibImpl>
|
||||
makePibWithKey(const Name& keyName, span<const uint8_t> key);
|
||||
|
||||
public:
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2013-2020 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.
|
||||
*/
|
||||
|
||||
#include "ndn-cxx/util/backports.hpp"
|
||||
|
||||
#include "tests/boost-test.hpp"
|
||||
|
||||
namespace ndn {
|
||||
namespace tests {
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(Util)
|
||||
BOOST_AUTO_TEST_SUITE(TestBackports)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Clamp)
|
||||
{
|
||||
int x = clamp(5, 1, 10);
|
||||
BOOST_CHECK_EQUAL(x, 5);
|
||||
|
||||
x = clamp(-5, 1, 10);
|
||||
BOOST_CHECK_EQUAL(x, 1);
|
||||
|
||||
x = clamp(15, 1, 10);
|
||||
BOOST_CHECK_EQUAL(x, 10);
|
||||
|
||||
x = clamp(5, 10, 1, std::greater<int>());
|
||||
BOOST_CHECK_EQUAL(x, 5);
|
||||
|
||||
x = clamp(-5, 10, 1, std::greater<int>());
|
||||
BOOST_CHECK_EQUAL(x, 1);
|
||||
|
||||
x = clamp(15, 10, 1, std::greater<int>());
|
||||
BOOST_CHECK_EQUAL(x, 10);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END() // TestBackports
|
||||
BOOST_AUTO_TEST_SUITE_END() // Util
|
||||
|
||||
} // namespace tests
|
||||
} // namespace ndn
|
||||
Reference in new issue
Block a user