diff --git a/COPYING.md b/COPYING.md index 9c4cb031..084ab1ff 100644 --- a/COPYING.md +++ b/COPYING.md @@ -9,9 +9,6 @@ ndn-cxx relies on third-party software, licensed under the following licenses: - OpenSSL is licensed under the [Apache License 2.0](https://www.openssl.org/source/license.html) -- optional-lite by Martin Moene is licensed under the - [Boost Software License 1.0](https://github.com/martinmoene/optional-lite/blob/master/LICENSE.txt) - - scope-lite by Martin Moene is licensed under the [Boost Software License 1.0](https://github.com/martinmoene/scope-lite/blob/master/LICENSE.txt) diff --git a/ndn-cxx/data.cpp b/ndn-cxx/data.cpp index 5997e1a7..3c55384c 100644 --- a/ndn-cxx/data.cpp +++ b/ndn-cxx/data.cpp @@ -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). * @@ -351,7 +351,7 @@ Data::setFreshnessPeriod(time::milliseconds freshnessPeriod) } Data& -Data::setFinalBlock(optional finalBlockId) +Data::setFinalBlock(std::optional finalBlockId) { if (finalBlockId != m_metaInfo.getFinalBlock()) { m_metaInfo.setFinalBlock(std::move(finalBlockId)); diff --git a/ndn-cxx/data.hpp b/ndn-cxx/data.hpp index 57e0c9a0..5467e49e 100644 --- a/ndn-cxx/data.hpp +++ b/ndn-cxx/data.hpp @@ -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). * @@ -299,14 +299,14 @@ public: // MetaInfo fields Data& setFreshnessPeriod(time::milliseconds freshnessPeriod); - const optional& + const std::optional& getFinalBlock() const { return m_metaInfo.getFinalBlock(); } Data& - setFinalBlock(optional finalBlockId); + setFinalBlock(std::optional finalBlockId); public: // SignatureInfo fields /** @@ -322,10 +322,13 @@ public: // SignatureInfo fields /** * @brief Get the `KeyLocator` element. */ - optional + std::optional getKeyLocator() const noexcept { - return m_signatureInfo.hasKeyLocator() ? make_optional(m_signatureInfo.getKeyLocator()) : nullopt; + if (m_signatureInfo.hasKeyLocator()) { + return m_signatureInfo.getKeyLocator(); + } + return std::nullopt; } protected: diff --git a/ndn-cxx/detail/common.hpp b/ndn-cxx/detail/common.hpp index c64e4d8f..0e2b4d4e 100644 --- a/ndn-cxx/detail/common.hpp +++ b/ndn-cxx/detail/common.hpp @@ -54,7 +54,6 @@ #include #include #include -#include #include #include #include diff --git a/ndn-cxx/detail/nonstd/optional-lite.hpp b/ndn-cxx/detail/nonstd/optional-lite.hpp deleted file mode 100644 index cc30bf53..00000000 --- a/ndn-cxx/detail/nonstd/optional-lite.hpp +++ /dev/null @@ -1,1847 +0,0 @@ -// -// Copyright (c) 2014-2021 Martin Moene -// -// https://github.com/martinmoene/optional-lite -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#pragma once - -#ifndef NONSTD_OPTIONAL_LITE_HPP -#define NONSTD_OPTIONAL_LITE_HPP - -#define optional_lite_MAJOR 3 -#define optional_lite_MINOR 5 -#define optional_lite_PATCH 0 - -#define optional_lite_VERSION optional_STRINGIFY(optional_lite_MAJOR) "." optional_STRINGIFY(optional_lite_MINOR) "." optional_STRINGIFY(optional_lite_PATCH) - -#define optional_STRINGIFY( x ) optional_STRINGIFY_( x ) -#define optional_STRINGIFY_( x ) #x - -// optional-lite configuration: - -#define optional_OPTIONAL_DEFAULT 0 -#define optional_OPTIONAL_NONSTD 1 -#define optional_OPTIONAL_STD 2 - -// tweak header support: - -#ifdef __has_include -# if __has_include() -# include -# endif -#define optional_HAVE_TWEAK_HEADER 1 -#else -#define optional_HAVE_TWEAK_HEADER 0 -//# pragma message("optional.hpp: Note: Tweak header not supported.") -#endif - -// optional selection and configuration: - -#if !defined( optional_CONFIG_SELECT_OPTIONAL ) -# define optional_CONFIG_SELECT_OPTIONAL ( optional_HAVE_STD_OPTIONAL ? optional_OPTIONAL_STD : optional_OPTIONAL_NONSTD ) -#endif - -// Control presence of extensions: - -#ifndef optional_CONFIG_NO_EXTENSIONS -#define optional_CONFIG_NO_EXTENSIONS 0 -#endif - -// Control presence of exception handling (try and auto discover): - -#ifndef optional_CONFIG_NO_EXCEPTIONS -# if defined(_MSC_VER) -# include // for _HAS_EXCEPTIONS -# endif -# if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || (defined(_HAS_EXCEPTIONS) && (_HAS_EXCEPTIONS)) -# define optional_CONFIG_NO_EXCEPTIONS 0 -# else -# define optional_CONFIG_NO_EXCEPTIONS 1 -# endif -#endif - -// C++ language version detection (C++23 is speculative): -// Note: VC14.0/1900 (VS2015) lacks too much from C++14. - -#ifndef optional_CPLUSPLUS -# if defined(_MSVC_LANG ) && !defined(__clang__) -# define optional_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG ) -# else -# define optional_CPLUSPLUS __cplusplus -# endif -#endif - -#define optional_CPP98_OR_GREATER ( optional_CPLUSPLUS >= 199711L ) -#define optional_CPP11_OR_GREATER ( optional_CPLUSPLUS >= 201103L ) -#define optional_CPP11_OR_GREATER_ ( optional_CPLUSPLUS >= 201103L ) -#define optional_CPP14_OR_GREATER ( optional_CPLUSPLUS >= 201402L ) -#define optional_CPP17_OR_GREATER ( optional_CPLUSPLUS >= 201703L ) -#define optional_CPP20_OR_GREATER ( optional_CPLUSPLUS >= 202002L ) -#define optional_CPP23_OR_GREATER ( optional_CPLUSPLUS >= 202300L ) - -// C++ language version (represent 98 as 3): - -#define optional_CPLUSPLUS_V ( optional_CPLUSPLUS / 100 - (optional_CPLUSPLUS > 200000 ? 2000 : 1994) ) - -// Use C++17 std::optional if available and requested: - -#if optional_CPP17_OR_GREATER && defined(__has_include ) -# if __has_include( ) -# define optional_HAVE_STD_OPTIONAL 1 -# else -# define optional_HAVE_STD_OPTIONAL 0 -# endif -#else -# define optional_HAVE_STD_OPTIONAL 0 -#endif - -#define optional_USES_STD_OPTIONAL ( (optional_CONFIG_SELECT_OPTIONAL == optional_OPTIONAL_STD) || ((optional_CONFIG_SELECT_OPTIONAL == optional_OPTIONAL_DEFAULT) && optional_HAVE_STD_OPTIONAL) ) - -// -// in_place: code duplicated in any-lite, expected-lite, optional-lite, value-ptr-lite, variant-lite: -// - -#ifndef nonstd_lite_HAVE_IN_PLACE_TYPES -#define nonstd_lite_HAVE_IN_PLACE_TYPES 1 - -// C++17 std::in_place in : - -#if optional_CPP17_OR_GREATER - -#include - -namespace nonstd { - -using std::in_place; -using std::in_place_type; -using std::in_place_index; -using std::in_place_t; -using std::in_place_type_t; -using std::in_place_index_t; - -#define nonstd_lite_in_place_t( T) std::in_place_t -#define nonstd_lite_in_place_type_t( T) std::in_place_type_t -#define nonstd_lite_in_place_index_t(K) std::in_place_index_t - -#define nonstd_lite_in_place( T) std::in_place_t{} -#define nonstd_lite_in_place_type( T) std::in_place_type_t{} -#define nonstd_lite_in_place_index(K) std::in_place_index_t{} - -} // namespace nonstd - -#else // optional_CPP17_OR_GREATER - -#include - -namespace nonstd { -namespace detail { - -template< class T > -struct in_place_type_tag {}; - -template< std::size_t K > -struct in_place_index_tag {}; - -} // namespace detail - -struct in_place_t {}; - -template< class T > -inline in_place_t in_place( detail::in_place_type_tag /*unused*/ = detail::in_place_type_tag() ) -{ - return in_place_t(); -} - -template< std::size_t K > -inline in_place_t in_place( detail::in_place_index_tag /*unused*/ = detail::in_place_index_tag() ) -{ - return in_place_t(); -} - -template< class T > -inline in_place_t in_place_type( detail::in_place_type_tag /*unused*/ = detail::in_place_type_tag() ) -{ - return in_place_t(); -} - -template< std::size_t K > -inline in_place_t in_place_index( detail::in_place_index_tag /*unused*/ = detail::in_place_index_tag() ) -{ - return in_place_t(); -} - -// mimic templated typedef: - -#define nonstd_lite_in_place_t( T) nonstd::in_place_t(&)( nonstd::detail::in_place_type_tag ) -#define nonstd_lite_in_place_type_t( T) nonstd::in_place_t(&)( nonstd::detail::in_place_type_tag ) -#define nonstd_lite_in_place_index_t(K) nonstd::in_place_t(&)( nonstd::detail::in_place_index_tag ) - -#define nonstd_lite_in_place( T) nonstd::in_place_type -#define nonstd_lite_in_place_type( T) nonstd::in_place_type -#define nonstd_lite_in_place_index(K) nonstd::in_place_index - -} // namespace nonstd - -#endif // optional_CPP17_OR_GREATER -#endif // nonstd_lite_HAVE_IN_PLACE_TYPES - -// -// Using std::optional: -// - -#if optional_USES_STD_OPTIONAL - -#include - -namespace nonstd { - - using std::optional; - using std::bad_optional_access; - using std::hash; - - using std::nullopt; - using std::nullopt_t; - - using std::operator==; - using std::operator!=; - using std::operator<; - using std::operator<=; - using std::operator>; - using std::operator>=; - using std::make_optional; - using std::swap; -} - -#else // optional_USES_STD_OPTIONAL - -#include -#include - -// optional-lite alignment configuration: - -#ifndef optional_CONFIG_MAX_ALIGN_HACK -# define optional_CONFIG_MAX_ALIGN_HACK 0 -#endif - -#ifndef optional_CONFIG_ALIGN_AS -// no default, used in #if defined() -#endif - -#ifndef optional_CONFIG_ALIGN_AS_FALLBACK -# define optional_CONFIG_ALIGN_AS_FALLBACK double -#endif - -// Compiler warning suppression: - -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wundef" -#elif defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wundef" -#elif defined(_MSC_VER ) -# pragma warning( push ) -#endif - -// half-open range [lo..hi): -#define optional_BETWEEN( v, lo, hi ) ( (lo) <= (v) && (v) < (hi) ) - -// Compiler versions: -// -// MSVC++ 6.0 _MSC_VER == 1200 optional_COMPILER_MSVC_VERSION == 60 (Visual Studio 6.0) -// MSVC++ 7.0 _MSC_VER == 1300 optional_COMPILER_MSVC_VERSION == 70 (Visual Studio .NET 2002) -// MSVC++ 7.1 _MSC_VER == 1310 optional_COMPILER_MSVC_VERSION == 71 (Visual Studio .NET 2003) -// MSVC++ 8.0 _MSC_VER == 1400 optional_COMPILER_MSVC_VERSION == 80 (Visual Studio 2005) -// MSVC++ 9.0 _MSC_VER == 1500 optional_COMPILER_MSVC_VERSION == 90 (Visual Studio 2008) -// MSVC++ 10.0 _MSC_VER == 1600 optional_COMPILER_MSVC_VERSION == 100 (Visual Studio 2010) -// MSVC++ 11.0 _MSC_VER == 1700 optional_COMPILER_MSVC_VERSION == 110 (Visual Studio 2012) -// MSVC++ 12.0 _MSC_VER == 1800 optional_COMPILER_MSVC_VERSION == 120 (Visual Studio 2013) -// MSVC++ 14.0 _MSC_VER == 1900 optional_COMPILER_MSVC_VERSION == 140 (Visual Studio 2015) -// MSVC++ 14.1 _MSC_VER >= 1910 optional_COMPILER_MSVC_VERSION == 141 (Visual Studio 2017) -// MSVC++ 14.2 _MSC_VER >= 1920 optional_COMPILER_MSVC_VERSION == 142 (Visual Studio 2019) - -#if defined(_MSC_VER ) && !defined(__clang__) -# define optional_COMPILER_MSVC_VER (_MSC_VER ) -# define optional_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * ( 5 + (_MSC_VER < 1900 ) ) ) -#else -# define optional_COMPILER_MSVC_VER 0 -# define optional_COMPILER_MSVC_VERSION 0 -#endif - -#define optional_COMPILER_VERSION( major, minor, patch ) ( 10 * (10 * (major) + (minor) ) + (patch) ) - -#if defined(__GNUC__) && !defined(__clang__) -# define optional_COMPILER_GNUC_VERSION optional_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -#else -# define optional_COMPILER_GNUC_VERSION 0 -#endif - -#if defined(__clang__) -# define optional_COMPILER_CLANG_VERSION optional_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__) -#else -# define optional_COMPILER_CLANG_VERSION 0 -#endif - -#if optional_BETWEEN(optional_COMPILER_MSVC_VERSION, 70, 140 ) -# pragma warning( disable: 4345 ) // initialization behavior changed -#endif - -#if optional_BETWEEN(optional_COMPILER_MSVC_VERSION, 70, 150 ) -# pragma warning( disable: 4814 ) // in C++14 'constexpr' will not imply 'const' -#endif - -// Presence of language and library features: - -#define optional_HAVE(FEATURE) ( optional_HAVE_##FEATURE ) - -#ifdef _HAS_CPP0X -# define optional_HAS_CPP0X _HAS_CPP0X -#else -# define optional_HAS_CPP0X 0 -#endif - -// Unless defined otherwise below, consider VC14 as C++11 for optional-lite: - -#if optional_COMPILER_MSVC_VER >= 1900 -# undef optional_CPP11_OR_GREATER -# define optional_CPP11_OR_GREATER 1 -#endif - -#define optional_CPP11_90 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1500) -#define optional_CPP11_100 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1600) -#define optional_CPP11_110 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1700) -#define optional_CPP11_120 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1800) -#define optional_CPP11_140 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1900) -#define optional_CPP11_141 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1910) - -#define optional_CPP14_000 (optional_CPP14_OR_GREATER) -#define optional_CPP17_000 (optional_CPP17_OR_GREATER) - -// clang >= 2.9, gcc >= 4.9, msvc >= vc14.0/1900 (vs15): -#define optional_CPP11_140_C290_G490 ((optional_CPP11_OR_GREATER_ && (optional_COMPILER_CLANG_VERSION >= 290 || optional_COMPILER_GNUC_VERSION >= 490)) || (optional_COMPILER_MSVC_VER >= 1900)) - -// clang >= 3.5, msvc >= vc11 (vs12): -#define optional_CPP11_110_C350 ( optional_CPP11_110 && !optional_BETWEEN( optional_COMPILER_CLANG_VERSION, 1, 350 ) ) - -// clang >= 3.5, gcc >= 5.0, msvc >= vc11 (vs12): -#define optional_CPP11_110_C350_G500 \ - ( optional_CPP11_110 && \ - !( optional_BETWEEN( optional_COMPILER_CLANG_VERSION, 1, 350 ) \ - || optional_BETWEEN( optional_COMPILER_GNUC_VERSION , 1, 500 ) ) ) - -// Presence of C++11 language features: - -#define optional_HAVE_CONSTEXPR_11 optional_CPP11_140 -#define optional_HAVE_IS_DEFAULT optional_CPP11_140 -#define optional_HAVE_NOEXCEPT optional_CPP11_140 -#define optional_HAVE_NULLPTR optional_CPP11_100 -#define optional_HAVE_REF_QUALIFIER optional_CPP11_140_C290_G490 -#define optional_HAVE_STATIC_ASSERT optional_CPP11_110 -#define optional_HAVE_INITIALIZER_LIST optional_CPP11_140 - -// Presence of C++14 language features: - -#define optional_HAVE_CONSTEXPR_14 optional_CPP14_000 - -// Presence of C++17 language features: - -#define optional_HAVE_NODISCARD optional_CPP17_000 - -// Presence of C++ library features: - -#define optional_HAVE_CONDITIONAL optional_CPP11_120 -#define optional_HAVE_REMOVE_CV optional_CPP11_120 -#define optional_HAVE_TYPE_TRAITS optional_CPP11_90 - -#define optional_HAVE_TR1_TYPE_TRAITS (!! optional_COMPILER_GNUC_VERSION ) -#define optional_HAVE_TR1_ADD_POINTER (!! optional_COMPILER_GNUC_VERSION ) - -#define optional_HAVE_IS_ASSIGNABLE optional_CPP11_110_C350 -#define optional_HAVE_IS_MOVE_CONSTRUCTIBLE optional_CPP11_110_C350 -#define optional_HAVE_IS_NOTHROW_MOVE_ASSIGNABLE optional_CPP11_110_C350 -#define optional_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE optional_CPP11_110_C350 -#define optional_HAVE_IS_TRIVIALLY_COPY_CONSTRUCTIBLE optional_CPP11_110_C350_G500 -#define optional_HAVE_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE optional_CPP11_110_C350_G500 - -// C++ feature usage: - -#if optional_HAVE( CONSTEXPR_11 ) -# define optional_constexpr constexpr -#else -# define optional_constexpr /*constexpr*/ -#endif - -#if optional_HAVE( IS_DEFAULT ) -# define optional_is_default = default; -#else -# define optional_is_default {} -#endif - -#if optional_HAVE( CONSTEXPR_14 ) -# define optional_constexpr14 constexpr -#else -# define optional_constexpr14 /*constexpr*/ -#endif - -#if optional_HAVE( NODISCARD ) -# define optional_nodiscard [[nodiscard]] -#else -# define optional_nodiscard /*[[nodiscard]]*/ -#endif - -#if optional_HAVE( NOEXCEPT ) -# define optional_noexcept noexcept -#else -# define optional_noexcept /*noexcept*/ -#endif - -#if optional_HAVE( NULLPTR ) -# define optional_nullptr nullptr -#else -# define optional_nullptr NULL -#endif - -#if optional_HAVE( REF_QUALIFIER ) -// NOLINTNEXTLINE( bugprone-macro-parentheses ) -# define optional_ref_qual & -# define optional_refref_qual && -#else -# define optional_ref_qual /*&*/ -# define optional_refref_qual /*&&*/ -#endif - -#if optional_HAVE( STATIC_ASSERT ) -# define optional_static_assert(expr, text) static_assert(expr, text); -#else -# define optional_static_assert(expr, text) /*static_assert(expr, text);*/ -#endif - -// additional includes: - -#if optional_CONFIG_NO_EXCEPTIONS -// already included: -#else -# include -#endif - -#if optional_CPP11_OR_GREATER -# include -#endif - -#if optional_HAVE( INITIALIZER_LIST ) -# include -#endif - -#if optional_HAVE( TYPE_TRAITS ) -# include -#elif optional_HAVE( TR1_TYPE_TRAITS ) -# include -#endif - -// Method enabling - -#if optional_CPP11_OR_GREATER - -#define optional_REQUIRES_0(...) \ - template< bool B = (__VA_ARGS__), typename std::enable_if::type = 0 > - -#define optional_REQUIRES_T(...) \ - , typename std::enable_if< (__VA_ARGS__), int >::type = 0 - -#define optional_REQUIRES_R(R, ...) \ - typename std::enable_if< (__VA_ARGS__), R>::type - -#define optional_REQUIRES_A(...) \ - , typename std::enable_if< (__VA_ARGS__), void*>::type = nullptr - -#endif - -// -// optional: -// - -namespace nonstd { namespace optional_lite { - -namespace std11 { - -template< class T, T v > struct integral_constant { enum { value = v }; }; -template< bool B > struct bool_constant : integral_constant{}; - -typedef bool_constant< true > true_type; -typedef bool_constant< false > false_type; - -#if optional_CPP11_OR_GREATER - using std::move; -#else - template< typename T > T & move( T & t ) { return t; } -#endif - -#if optional_HAVE( CONDITIONAL ) - using std::conditional; -#else - template< bool B, typename T, typename F > struct conditional { typedef T type; }; - template< typename T, typename F > struct conditional { typedef F type; }; -#endif // optional_HAVE_CONDITIONAL - -#if optional_HAVE( IS_ASSIGNABLE ) - using std::is_assignable; -#else - template< class T, class U > struct is_assignable : std11::true_type{}; -#endif - -#if optional_HAVE( IS_MOVE_CONSTRUCTIBLE ) - using std::is_move_constructible; -#else - template< class T > struct is_move_constructible : std11::true_type{}; -#endif - -#if optional_HAVE( IS_NOTHROW_MOVE_ASSIGNABLE ) - using std::is_nothrow_move_assignable; -#else - template< class T > struct is_nothrow_move_assignable : std11::true_type{}; -#endif - -#if optional_HAVE( IS_NOTHROW_MOVE_CONSTRUCTIBLE ) - using std::is_nothrow_move_constructible; -#else - template< class T > struct is_nothrow_move_constructible : std11::true_type{}; -#endif - -#if optional_HAVE( IS_TRIVIALLY_COPY_CONSTRUCTIBLE ) - using std::is_trivially_copy_constructible; -#else - template< class T > struct is_trivially_copy_constructible : std11::true_type{}; -#endif - -#if optional_HAVE( IS_TRIVIALLY_MOVE_CONSTRUCTIBLE ) - using std::is_trivially_move_constructible; -#else - template< class T > struct is_trivially_move_constructible : std11::true_type{}; -#endif - -} // namespace std11 - -#if optional_CPP11_OR_GREATER - -/// type traits C++17: - -namespace std17 { - -#if optional_CPP17_OR_GREATER - -using std::is_swappable; -using std::is_nothrow_swappable; - -#elif optional_CPP11_OR_GREATER - -namespace detail { - -using std::swap; - -struct is_swappable -{ - template< typename T, typename = decltype( swap( std::declval(), std::declval() ) ) > - static std11::true_type test( int /*unused*/ ); - - template< typename > - static std11::false_type test(...); -}; - -struct is_nothrow_swappable -{ - // wrap noexcept(expr) in separate function as work-around for VC140 (VS2015): - - template< typename T > - static constexpr bool satisfies() - { - return noexcept( swap( std::declval(), std::declval() ) ); - } - - template< typename T > - static auto test( int /*unused*/ ) -> std11::integral_constant()>{} - - template< typename > - static auto test(...) -> std11::false_type; -}; - -} // namespace detail - -// is [nothow] swappable: - -template< typename T > -struct is_swappable : decltype( detail::is_swappable::test(0) ){}; - -template< typename T > -struct is_nothrow_swappable : decltype( detail::is_nothrow_swappable::test(0) ){}; - -#endif // optional_CPP17_OR_GREATER - -} // namespace std17 - -/// type traits C++20: - -namespace std20 { - -template< typename T > -struct remove_cvref -{ - typedef typename std::remove_cv< typename std::remove_reference::type >::type type; -}; - -} // namespace std20 - -#endif // optional_CPP11_OR_GREATER - -/// class optional - -template< typename T > -class optional; - -namespace detail { - -// C++11 emulation: - -struct nulltype{}; - -template< typename Head, typename Tail > -struct typelist -{ - typedef Head head; - typedef Tail tail; -}; - -#if optional_CONFIG_MAX_ALIGN_HACK - -// Max align, use most restricted type for alignment: - -#define optional_UNIQUE( name ) optional_UNIQUE2( name, __LINE__ ) -#define optional_UNIQUE2( name, line ) optional_UNIQUE3( name, line ) -#define optional_UNIQUE3( name, line ) name ## line - -#define optional_ALIGN_TYPE( type ) \ - type optional_UNIQUE( _t ); struct_t< type > optional_UNIQUE( _st ) - -template< typename T > -struct struct_t { T _; }; - -union max_align_t -{ - optional_ALIGN_TYPE( char ); - optional_ALIGN_TYPE( short int ); - optional_ALIGN_TYPE( int ); - optional_ALIGN_TYPE( long int ); - optional_ALIGN_TYPE( float ); - optional_ALIGN_TYPE( double ); - optional_ALIGN_TYPE( long double ); - optional_ALIGN_TYPE( char * ); - optional_ALIGN_TYPE( short int * ); - optional_ALIGN_TYPE( int * ); - optional_ALIGN_TYPE( long int * ); - optional_ALIGN_TYPE( float * ); - optional_ALIGN_TYPE( double * ); - optional_ALIGN_TYPE( long double * ); - optional_ALIGN_TYPE( void * ); - -#ifdef HAVE_LONG_LONG - optional_ALIGN_TYPE( long long ); -#endif - - struct Unknown; - - Unknown ( * optional_UNIQUE(_) )( Unknown ); - Unknown * Unknown::* optional_UNIQUE(_); - Unknown ( Unknown::* optional_UNIQUE(_) )( Unknown ); - - struct_t< Unknown ( * )( Unknown) > optional_UNIQUE(_); - struct_t< Unknown * Unknown::* > optional_UNIQUE(_); - struct_t< Unknown ( Unknown::* )(Unknown) > optional_UNIQUE(_); -}; - -#undef optional_UNIQUE -#undef optional_UNIQUE2 -#undef optional_UNIQUE3 - -#undef optional_ALIGN_TYPE - -#elif defined( optional_CONFIG_ALIGN_AS ) // optional_CONFIG_MAX_ALIGN_HACK - -// Use user-specified type for alignment: - -#define optional_ALIGN_AS( unused ) \ - optional_CONFIG_ALIGN_AS - -#else // optional_CONFIG_MAX_ALIGN_HACK - -// Determine POD type to use for alignment: - -#define optional_ALIGN_AS( to_align ) \ - typename type_of_size< alignment_types, alignment_of< to_align >::value >::type - -template< typename T > -struct alignment_of; - -template< typename T > -struct alignment_of_hack -{ - char c; - T t; - alignment_of_hack(); -}; - -template< size_t A, size_t S > -struct alignment_logic -{ - enum { value = A < S ? A : S }; -}; - -template< typename T > -struct alignment_of -{ - enum { value = alignment_logic< - sizeof( alignment_of_hack ) - sizeof(T), sizeof(T) >::value }; -}; - -template< typename List, size_t N > -struct type_of_size -{ - typedef typename std11::conditional< - N == sizeof( typename List::head ), - typename List::head, - typename type_of_size::type >::type type; -}; - -template< size_t N > -struct type_of_size< nulltype, N > -{ - typedef optional_CONFIG_ALIGN_AS_FALLBACK type; -}; - -template< typename T> -struct struct_t { T _; }; - -#define optional_ALIGN_TYPE( type ) \ - typelist< type , typelist< struct_t< type > - -struct Unknown; - -typedef - optional_ALIGN_TYPE( char ), - optional_ALIGN_TYPE( short ), - optional_ALIGN_TYPE( int ), - optional_ALIGN_TYPE( long ), - optional_ALIGN_TYPE( float ), - optional_ALIGN_TYPE( double ), - optional_ALIGN_TYPE( long double ), - - optional_ALIGN_TYPE( char *), - optional_ALIGN_TYPE( short * ), - optional_ALIGN_TYPE( int * ), - optional_ALIGN_TYPE( long * ), - optional_ALIGN_TYPE( float * ), - optional_ALIGN_TYPE( double * ), - optional_ALIGN_TYPE( long double * ), - - optional_ALIGN_TYPE( Unknown ( * )( Unknown ) ), - optional_ALIGN_TYPE( Unknown * Unknown::* ), - optional_ALIGN_TYPE( Unknown ( Unknown::* )( Unknown ) ), - - nulltype - > > > > > > > > > > > > > > - > > > > > > > > > > > > > > - > > > > > > - alignment_types; - -#undef optional_ALIGN_TYPE - -#endif // optional_CONFIG_MAX_ALIGN_HACK - -/// C++03 constructed union to hold value. - -template< typename T > -union storage_t -{ -//private: -// template< typename > friend class optional; - - typedef T value_type; - - storage_t() optional_is_default - - explicit storage_t( value_type const & v ) - { - construct_value( v ); - } - - void construct_value( value_type const & v ) - { - ::new( value_ptr() ) value_type( v ); - } - -#if optional_CPP11_OR_GREATER - - explicit storage_t( value_type && v ) - { - construct_value( std::move( v ) ); - } - - void construct_value( value_type && v ) - { - ::new( value_ptr() ) value_type( std::move( v ) ); - } - - template< class... Args > - storage_t( nonstd_lite_in_place_t(T), Args&&... args ) - { - emplace( std::forward(args)... ); - } - - template< class... Args > - void emplace( Args&&... args ) - { - ::new( value_ptr() ) value_type( std::forward(args)... ); - } - - template< class U, class... Args > - void emplace( std::initializer_list il, Args&&... args ) - { - ::new( value_ptr() ) value_type( il, std::forward(args)... ); - } - -#endif - - void destruct_value() - { - value_ptr()->~T(); - } - - optional_nodiscard value_type const * value_ptr() const - { - return as(); - } - - value_type * value_ptr() - { - return as(); - } - - optional_nodiscard value_type const & value() const optional_ref_qual - { - return * value_ptr(); - } - - value_type & value() optional_ref_qual - { - return * value_ptr(); - } - -#if optional_HAVE( REF_QUALIFIER ) - - optional_nodiscard value_type const && value() const optional_refref_qual - { - return std::move( value() ); - } - - value_type && value() optional_refref_qual - { - return std::move( value() ); - } - -#endif - -#if optional_CPP11_OR_GREATER - - using aligned_storage_t = typename std::aligned_storage< sizeof(value_type), alignof(value_type) >::type; - aligned_storage_t data; - -#elif optional_CONFIG_MAX_ALIGN_HACK - - typedef struct { unsigned char data[ sizeof(value_type) ]; } aligned_storage_t; - - max_align_t hack; - aligned_storage_t data; - -#else - typedef optional_ALIGN_AS(value_type) align_as_type; - - typedef struct { align_as_type data[ 1 + ( sizeof(value_type) - 1 ) / sizeof(align_as_type) ]; } aligned_storage_t; - aligned_storage_t data; - -# undef optional_ALIGN_AS - -#endif // optional_CONFIG_MAX_ALIGN_HACK - - optional_nodiscard void * ptr() optional_noexcept - { - return &data; - } - - optional_nodiscard void const * ptr() const optional_noexcept - { - return &data; - } - - template - optional_nodiscard U * as() - { - return reinterpret_cast( ptr() ); - } - - template - optional_nodiscard U const * as() const - { - return reinterpret_cast( ptr() ); - } -}; - -} // namespace detail - -/// disengaged state tag - -struct nullopt_t -{ - struct init{}; - explicit optional_constexpr nullopt_t( init /*unused*/ ) optional_noexcept {} -}; - -#if optional_HAVE( CONSTEXPR_11 ) -constexpr nullopt_t nullopt{ nullopt_t::init{} }; -#else -// extra parenthesis to prevent the most vexing parse: -const nullopt_t nullopt(( nullopt_t::init() )); -#endif - -/// optional access error - -#if ! optional_CONFIG_NO_EXCEPTIONS - -class bad_optional_access : public std::logic_error -{ -public: - explicit bad_optional_access() - : logic_error( "bad optional access" ) {} -}; - -#endif //optional_CONFIG_NO_EXCEPTIONS - -/// optional - -template< typename T> -class optional -{ - optional_static_assert(( !std::is_same::type, nullopt_t>::value ), - "T in optional must not be of type 'nullopt_t'.") - - optional_static_assert(( !std::is_same::type, in_place_t>::value ), - "T in optional must not be of type 'in_place_t'.") - - optional_static_assert(( std::is_object::value && std::is_destructible::value && !std::is_array::value ), - "T in optional must meet the Cpp17Destructible requirements.") - -private: - template< typename > friend class optional; - - typedef void (optional::*safe_bool)() const; - -public: - typedef T value_type; - - // x.x.3.1, constructors - - // 1a - default construct - optional_constexpr optional() optional_noexcept - : has_value_( false ) - , contained() - {} - - // 1b - construct explicitly empty - // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions ) - optional_constexpr optional( nullopt_t /*unused*/ ) optional_noexcept - : has_value_( false ) - , contained() - {} - - // 2 - copy-construct -#if optional_CPP11_OR_GREATER - // template< typename U = T - // optional_REQUIRES_T( - // std::is_copy_constructible::value - // || std11::is_trivially_copy_constructible::value - // ) - // > -#endif - optional_constexpr14 optional( optional const & other ) - : has_value_( other.has_value() ) - { - if ( other.has_value() ) - { - contained.construct_value( other.contained.value() ); - } - } - -#if optional_CPP11_OR_GREATER - - // 3 (C++11) - move-construct from optional - template< typename U = T - optional_REQUIRES_T( - std11::is_move_constructible::value - || std11::is_trivially_move_constructible::value - ) - > - optional_constexpr14 optional( optional && other ) - // NOLINTNEXTLINE( performance-noexcept-move-constructor ) - noexcept( std11::is_nothrow_move_constructible::value ) - : has_value_( other.has_value() ) - { - if ( other.has_value() ) - { - contained.construct_value( std::move( other.contained.value() ) ); - } - } - - // 4a (C++11) - explicit converting copy-construct from optional - template< typename U - optional_REQUIRES_T( - std::is_constructible::value - && !std::is_constructible & >::value - && !std::is_constructible && >::value - && !std::is_constructible const & >::value - && !std::is_constructible const && >::value - && !std::is_convertible< optional & , T>::value - && !std::is_convertible< optional && , T>::value - && !std::is_convertible< optional const & , T>::value - && !std::is_convertible< optional const &&, T>::value - && !std::is_convertible< U const & , T>::value /*=> explicit */ - ) - > - explicit optional( optional const & other ) - : has_value_( other.has_value() ) - { - if ( other.has_value() ) - { - contained.construct_value( T{ other.contained.value() } ); - } - } -#endif // optional_CPP11_OR_GREATER - - // 4b (C++98 and later) - non-explicit converting copy-construct from optional - template< typename U -#if optional_CPP11_OR_GREATER - optional_REQUIRES_T( - std::is_constructible::value - && !std::is_constructible & >::value - && !std::is_constructible && >::value - && !std::is_constructible const & >::value - && !std::is_constructible const && >::value - && !std::is_convertible< optional & , T>::value - && !std::is_convertible< optional && , T>::value - && !std::is_convertible< optional const & , T>::value - && !std::is_convertible< optional const &&, T>::value - && std::is_convertible< U const & , T>::value /*=> non-explicit */ - ) -#endif // optional_CPP11_OR_GREATER - > - // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions ) - /*non-explicit*/ optional( optional const & other ) - : has_value_( other.has_value() ) - { - if ( other.has_value() ) - { - contained.construct_value( other.contained.value() ); - } - } - -#if optional_CPP11_OR_GREATER - - // 5a (C++11) - explicit converting move-construct from optional - template< typename U - optional_REQUIRES_T( - std::is_constructible::value - && !std::is_constructible & >::value - && !std::is_constructible && >::value - && !std::is_constructible const & >::value - && !std::is_constructible const && >::value - && !std::is_convertible< optional & , T>::value - && !std::is_convertible< optional && , T>::value - && !std::is_convertible< optional const & , T>::value - && !std::is_convertible< optional const &&, T>::value - && !std::is_convertible< U &&, T>::value /*=> explicit */ - ) - > - explicit optional( optional && other - ) - : has_value_( other.has_value() ) - { - if ( other.has_value() ) - { - contained.construct_value( T{ std::move( other.contained.value() ) } ); - } - } - - // 5a (C++11) - non-explicit converting move-construct from optional - template< typename U - optional_REQUIRES_T( - std::is_constructible::value - && !std::is_constructible & >::value - && !std::is_constructible && >::value - && !std::is_constructible const & >::value - && !std::is_constructible const && >::value - && !std::is_convertible< optional & , T>::value - && !std::is_convertible< optional && , T>::value - && !std::is_convertible< optional const & , T>::value - && !std::is_convertible< optional const &&, T>::value - && std::is_convertible< U &&, T>::value /*=> non-explicit */ - ) - > - // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions ) - /*non-explicit*/ optional( optional && other ) - : has_value_( other.has_value() ) - { - if ( other.has_value() ) - { - contained.construct_value( std::move( other.contained.value() ) ); - } - } - - // 6 (C++11) - in-place construct - template< typename... Args - optional_REQUIRES_T( - std::is_constructible::value - ) - > - optional_constexpr explicit optional( nonstd_lite_in_place_t(T), Args&&... args ) - : has_value_( true ) - , contained( in_place, std::forward(args)... ) - {} - - // 7 (C++11) - in-place construct, initializer-list - template< typename U, typename... Args - optional_REQUIRES_T( - std::is_constructible&, Args&&...>::value - ) - > - optional_constexpr explicit optional( nonstd_lite_in_place_t(T), std::initializer_list il, Args&&... args ) - : has_value_( true ) - , contained( T( il, std::forward(args)...) ) - {} - - // 8a (C++11) - explicit move construct from value - template< typename U = T - optional_REQUIRES_T( - std::is_constructible::value - && !std::is_same::type, nonstd_lite_in_place_t(U)>::value - && !std::is_same::type, optional>::value - && !std::is_convertible::value /*=> explicit */ - ) - > - optional_constexpr explicit optional( U && value ) - : has_value_( true ) - , contained( nonstd_lite_in_place(T), std::forward( value ) ) - {} - - // 8b (C++11) - non-explicit move construct from value - template< typename U = T - optional_REQUIRES_T( - std::is_constructible::value - && !std::is_same::type, nonstd_lite_in_place_t(U)>::value - && !std::is_same::type, optional>::value - && std::is_convertible::value /*=> non-explicit */ - ) - > - // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions ) - optional_constexpr /*non-explicit*/ optional( U && value ) - : has_value_( true ) - , contained( nonstd_lite_in_place(T), std::forward( value ) ) - {} - -#else // optional_CPP11_OR_GREATER - - // 8 (C++98) - optional( value_type const & value ) - : has_value_( true ) - , contained( value ) - {} - -#endif // optional_CPP11_OR_GREATER - - // x.x.3.2, destructor - - ~optional() - { - if ( has_value() ) - { - contained.destruct_value(); - } - } - - // x.x.3.3, assignment - - // 1 (C++98and later) - assign explicitly empty - optional & operator=( nullopt_t /*unused*/) optional_noexcept - { - reset(); - return *this; - } - - // 2 (C++98and later) - copy-assign from optional -#if optional_CPP11_OR_GREATER - // NOLINTNEXTLINE( cppcoreguidelines-c-copy-assignment-signature, misc-unconventional-assign-operator ) - optional_REQUIRES_R( - optional &, - true -// std::is_copy_constructible::value -// && std::is_copy_assignable::value - ) - operator=( optional const & other ) - noexcept( - std11::is_nothrow_move_assignable::value - && std11::is_nothrow_move_constructible::value - ) -#else - optional & operator=( optional const & other ) -#endif - { - if ( (has_value() == true ) && (other.has_value() == false) ) { reset(); } - else if ( (has_value() == false) && (other.has_value() == true ) ) { initialize( *other ); } - else if ( (has_value() == true ) && (other.has_value() == true ) ) { contained.value() = *other; } - return *this; - } - -#if optional_CPP11_OR_GREATER - - // 3 (C++11) - move-assign from optional - // NOLINTNEXTLINE( cppcoreguidelines-c-copy-assignment-signature, misc-unconventional-assign-operator ) - optional_REQUIRES_R( - optional &, - true -// std11::is_move_constructible::value -// && std::is_move_assignable::value - ) - operator=( optional && other ) noexcept - { - if ( (has_value() == true ) && (other.has_value() == false) ) { reset(); } - else if ( (has_value() == false) && (other.has_value() == true ) ) { initialize( std::move( *other ) ); } - else if ( (has_value() == true ) && (other.has_value() == true ) ) { contained.value() = std::move( *other ); } - return *this; - } - - // 4 (C++11) - move-assign from value - template< typename U = T > - // NOLINTNEXTLINE( cppcoreguidelines-c-copy-assignment-signature, misc-unconventional-assign-operator ) - optional_REQUIRES_R( - optional &, - std::is_constructible::value - && std11::is_assignable::value - && !std::is_same::type, nonstd_lite_in_place_t(U)>::value - && !std::is_same::type, optional>::value - && !(std::is_scalar::value && std::is_same::type>::value) - ) - operator=( U && value ) - { - if ( has_value() ) - { - contained.value() = std::forward( value ); - } - else - { - initialize( T( std::forward( value ) ) ); - } - return *this; - } - -#else // optional_CPP11_OR_GREATER - - // 4 (C++98) - copy-assign from value - template< typename U /*= T*/ > - optional & operator=( U const & value ) - { - if ( has_value() ) contained.value() = value; - else initialize( T( value ) ); - return *this; - } - -#endif // optional_CPP11_OR_GREATER - - // 5 (C++98 and later) - converting copy-assign from optional - template< typename U > -#if optional_CPP11_OR_GREATER - // NOLINTNEXTLINE( cppcoreguidelines-c-copy-assignment-signature, misc-unconventional-assign-operator ) - optional_REQUIRES_R( - optional&, - std::is_constructible< T , U const &>::value - && std11::is_assignable< T&, U const &>::value - && !std::is_constructible & >::value - && !std::is_constructible && >::value - && !std::is_constructible const & >::value - && !std::is_constructible const && >::value - && !std::is_convertible< optional & , T>::value - && !std::is_convertible< optional && , T>::value - && !std::is_convertible< optional const & , T>::value - && !std::is_convertible< optional const &&, T>::value - && !std11::is_assignable< T&, optional & >::value - && !std11::is_assignable< T&, optional && >::value - && !std11::is_assignable< T&, optional const & >::value - && !std11::is_assignable< T&, optional const && >::value - ) -#else - optional& -#endif // optional_CPP11_OR_GREATER - operator=( optional const & other ) - { - return *this = optional( other ); - } - -#if optional_CPP11_OR_GREATER - - // 6 (C++11) - converting move-assign from optional - template< typename U > - // NOLINTNEXTLINE( cppcoreguidelines-c-copy-assignment-signature, misc-unconventional-assign-operator ) - optional_REQUIRES_R( - optional&, - std::is_constructible< T , U>::value - && std11::is_assignable< T&, U>::value - && !std::is_constructible & >::value - && !std::is_constructible && >::value - && !std::is_constructible const & >::value - && !std::is_constructible const && >::value - && !std::is_convertible< optional & , T>::value - && !std::is_convertible< optional && , T>::value - && !std::is_convertible< optional const & , T>::value - && !std::is_convertible< optional const &&, T>::value - && !std11::is_assignable< T&, optional & >::value - && !std11::is_assignable< T&, optional && >::value - && !std11::is_assignable< T&, optional const & >::value - && !std11::is_assignable< T&, optional const && >::value - ) - operator=( optional && other ) - { - return *this = optional( std::move( other ) ); - } - - // 7 (C++11) - emplace - template< typename... Args - optional_REQUIRES_T( - std::is_constructible::value - ) - > - T& emplace( Args&&... args ) - { - *this = nullopt; - contained.emplace( std::forward(args)... ); - has_value_ = true; - return contained.value(); - } - - // 8 (C++11) - emplace, initializer-list - template< typename U, typename... Args - optional_REQUIRES_T( - std::is_constructible&, Args&&...>::value - ) - > - T& emplace( std::initializer_list il, Args&&... args ) - { - *this = nullopt; - contained.emplace( il, std::forward(args)... ); - has_value_ = true; - return contained.value(); - } - -#endif // optional_CPP11_OR_GREATER - - // x.x.3.4, swap - - void swap( optional & other ) -#if optional_CPP11_OR_GREATER - noexcept( - std11::is_nothrow_move_constructible::value - && std17::is_nothrow_swappable::value - ) -#endif - { - using std::swap; - if ( (has_value() == true ) && (other.has_value() == true ) ) { swap( **this, *other ); } - else if ( (has_value() == false) && (other.has_value() == true ) ) { initialize( std11::move(*other) ); other.reset(); } - else if ( (has_value() == true ) && (other.has_value() == false) ) { other.initialize( std11::move(**this) ); reset(); } - } - - // x.x.3.5, observers - - optional_constexpr value_type const * operator ->() const - { - return assert( has_value() ), - contained.value_ptr(); - } - - optional_constexpr14 value_type * operator ->() - { - return assert( has_value() ), - contained.value_ptr(); - } - - optional_constexpr value_type const & operator *() const optional_ref_qual - { - return assert( has_value() ), - contained.value(); - } - - optional_constexpr14 value_type & operator *() optional_ref_qual - { - return assert( has_value() ), - contained.value(); - } - -#if optional_HAVE( REF_QUALIFIER ) - - optional_constexpr value_type const && operator *() const optional_refref_qual - { - return std::move( **this ); - } - - optional_constexpr14 value_type && operator *() optional_refref_qual - { - return std::move( **this ); - } - -#endif - -#if optional_CPP11_OR_GREATER - optional_constexpr explicit operator bool() const optional_noexcept - { - return has_value(); - } -#else - optional_constexpr operator safe_bool() const optional_noexcept - { - return has_value() ? &optional::this_type_does_not_support_comparisons : 0; - } -#endif - - // NOLINTNEXTLINE( modernize-use-nodiscard ) - /*optional_nodiscard*/ optional_constexpr bool has_value() const optional_noexcept - { - return has_value_; - } - - // NOLINTNEXTLINE( modernize-use-nodiscard ) - /*optional_nodiscard*/ optional_constexpr14 value_type const & value() const optional_ref_qual - { -#if optional_CONFIG_NO_EXCEPTIONS - assert( has_value() ); -#else - if ( ! has_value() ) - { - throw bad_optional_access(); - } -#endif - return contained.value(); - } - - optional_constexpr14 value_type & value() optional_ref_qual - { -#if optional_CONFIG_NO_EXCEPTIONS - assert( has_value() ); -#else - if ( ! has_value() ) - { - throw bad_optional_access(); - } -#endif - return contained.value(); - } - -#if optional_HAVE( REF_QUALIFIER ) && ( !optional_COMPILER_GNUC_VERSION || optional_COMPILER_GNUC_VERSION >= 490 ) - - // NOLINTNEXTLINE( modernize-use-nodiscard ) - /*optional_nodiscard*/ optional_constexpr value_type const && value() const optional_refref_qual - { - return std::move( value() ); - } - - optional_constexpr14 value_type && value() optional_refref_qual - { - return std::move( value() ); - } - -#endif - -#if optional_HAVE( REF_QUALIFIER ) - - template< typename U > - optional_constexpr value_type value_or( U && v ) const optional_ref_qual - { - return has_value() ? contained.value() : static_cast(std::forward( v ) ); - } - - template< typename U > - optional_constexpr14 value_type value_or( U && v ) optional_refref_qual - { -#if optional_COMPILER_CLANG_VERSION - return has_value() ? /*std::move*/( contained.value() ) : static_cast(std::forward( v ) ); -#else - return has_value() ? std::move( contained.value() ) : static_cast(std::forward( v ) ); -#endif - } - -#else - - template< typename U > - optional_constexpr value_type value_or( U const & v ) const - { - return has_value() ? contained.value() : static_cast( v ); - } - -#endif // optional_HAVE( REF_QUALIFIER ) - -#if !optional_CONFIG_NO_EXTENSIONS -#if optional_HAVE( REF_QUALIFIER ) - - template< typename F > - optional_constexpr value_type value_or_eval( F f ) const & - { - return has_value() ? contained.value() : f(); - } - - template< typename F > - optional_constexpr14 value_type value_or_eval( F f ) && - { - if ( has_value() ) - { - return std::move( contained.value() ); - } - else - { - return f(); - } - } - -#else - - template< typename F > - optional_constexpr value_type value_or_eval( F f ) const - { - return has_value() ? contained.value() : f(); - } - -#endif // optional_HAVE( REF_QUALIFIER ) -#endif // !optional_CONFIG_NO_EXTENSIONS - - // x.x.3.6, modifiers - - void reset() optional_noexcept - { - if ( has_value() ) - { - contained.destruct_value(); - } - - has_value_ = false; - } - -private: - void this_type_does_not_support_comparisons() const {} - - template< typename V > - void initialize( V const & value ) - { - assert( ! has_value() ); - contained.construct_value( value ); - has_value_ = true; - } - -#if optional_CPP11_OR_GREATER - template< typename V > - void initialize( V && value ) - { - assert( ! has_value() ); - contained.construct_value( std::move( value ) ); - has_value_ = true; - } - -#endif - -private: - bool has_value_; - detail::storage_t< value_type > contained; - -}; - -// Relational operators - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator==( optional const & x, optional const & y ) -{ - return bool(x) != bool(y) ? false : !bool( x ) ? true : *x == *y; -} - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator!=( optional const & x, optional const & y ) -{ - return !(x == y); -} - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator<( optional const & x, optional const & y ) -{ - return (!y) ? false : (!x) ? true : *x < *y; -} - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator>( optional const & x, optional const & y ) -{ - return (y < x); -} - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator<=( optional const & x, optional const & y ) -{ - return !(y < x); -} - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator>=( optional const & x, optional const & y ) -{ - return !(x < y); -} - -// Comparison with nullopt - -template< typename T > -optional_nodiscard optional_constexpr bool operator==( optional const & x, nullopt_t /*unused*/ ) optional_noexcept -{ - return (!x); -} - -template< typename T > -optional_nodiscard optional_constexpr bool operator==( nullopt_t /*unused*/, optional const & x ) optional_noexcept -{ - return (!x); -} - -template< typename T > -optional_nodiscard optional_constexpr bool operator!=( optional const & x, nullopt_t /*unused*/ ) optional_noexcept -{ - return bool(x); -} - -template< typename T > -optional_nodiscard optional_constexpr bool operator!=( nullopt_t /*unused*/, optional const & x ) optional_noexcept -{ - return bool(x); -} - -template< typename T > -optional_nodiscard optional_constexpr bool operator<( optional const & /*unused*/, nullopt_t /*unused*/ ) optional_noexcept -{ - return false; -} - -template< typename T > -optional_nodiscard optional_constexpr bool operator<( nullopt_t /*unused*/, optional const & x ) optional_noexcept -{ - return bool(x); -} - -template< typename T > -optional_nodiscard optional_constexpr bool operator<=( optional const & x, nullopt_t /*unused*/ ) optional_noexcept -{ - return (!x); -} - -template< typename T > -optional_nodiscard optional_constexpr bool operator<=( nullopt_t /*unused*/, optional const & /*unused*/ ) optional_noexcept -{ - return true; -} - -template< typename T > -optional_nodiscard optional_constexpr bool operator>( optional const & x, nullopt_t /*unused*/ ) optional_noexcept -{ - return bool(x); -} - -template< typename T > -optional_nodiscard optional_constexpr bool operator>( nullopt_t /*unused*/, optional const & /*unused*/ ) optional_noexcept -{ - return false; -} - -template< typename T > -optional_nodiscard optional_constexpr bool operator>=( optional const & /*unused*/, nullopt_t /*unused*/ ) optional_noexcept -{ - return true; -} - -template< typename T > -optional_nodiscard optional_constexpr bool operator>=( nullopt_t /*unused*/, optional const & x ) optional_noexcept -{ - return (!x); -} - -// Comparison with T - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator==( optional const & x, U const & v ) -{ - return bool(x) ? *x == v : false; -} - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator==( U const & v, optional const & x ) -{ - return bool(x) ? v == *x : false; -} - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator!=( optional const & x, U const & v ) -{ - return bool(x) ? *x != v : true; -} - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator!=( U const & v, optional const & x ) -{ - return bool(x) ? v != *x : true; -} - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator<( optional const & x, U const & v ) -{ - return bool(x) ? *x < v : true; -} - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator<( U const & v, optional const & x ) -{ - return bool(x) ? v < *x : false; -} - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator<=( optional const & x, U const & v ) -{ - return bool(x) ? *x <= v : true; -} - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator<=( U const & v, optional const & x ) -{ - return bool(x) ? v <= *x : false; -} - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator>( optional const & x, U const & v ) -{ - return bool(x) ? *x > v : false; -} - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator>( U const & v, optional const & x ) -{ - return bool(x) ? v > *x : true; -} - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator>=( optional const & x, U const & v ) -{ - return bool(x) ? *x >= v : false; -} - -template< typename T, typename U > -optional_nodiscard optional_constexpr bool operator>=( U const & v, optional const & x ) -{ - return bool(x) ? v >= *x : true; -} - -// Specialized algorithms - -template< typename T -#if optional_CPP11_OR_GREATER - optional_REQUIRES_T( - std11::is_move_constructible::value - && std17::is_swappable::value ) -#endif -> -void swap( optional & x, optional & y ) -#if optional_CPP11_OR_GREATER - noexcept( noexcept( x.swap(y) ) ) -#endif -{ - x.swap( y ); -} - -#if optional_CPP11_OR_GREATER - -template< typename T > -optional_constexpr optional< typename std::decay::type > make_optional( T && value ) -{ - return optional< typename std::decay::type >( std::forward( value ) ); -} - -template< typename T, typename...Args > -optional_constexpr optional make_optional( Args&&... args ) -{ - return optional( nonstd_lite_in_place(T), std::forward(args)...); -} - -template< typename T, typename U, typename... Args > -optional_constexpr optional make_optional( std::initializer_list il, Args&&... args ) -{ - return optional( nonstd_lite_in_place(T), il, std::forward(args)...); -} - -#else - -template< typename T > -optional make_optional( T const & value ) -{ - return optional( value ); -} - -#endif // optional_CPP11_OR_GREATER - -} // namespace optional_lite - -using optional_lite::optional; -using optional_lite::nullopt_t; -using optional_lite::nullopt; - -#if ! optional_CONFIG_NO_EXCEPTIONS -using optional_lite::bad_optional_access; -#endif - -using optional_lite::make_optional; - -} // namespace nonstd - -#if optional_CPP11_OR_GREATER - -// specialize the std::hash algorithm: - -namespace std { - -template< class T > -struct hash< nonstd::optional > -{ -public: - std::size_t operator()( nonstd::optional const & v ) const optional_noexcept - { - return bool( v ) ? std::hash{}( *v ) : 0; - } -}; - -} //namespace std - -#endif // optional_CPP11_OR_GREATER - -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined(__GNUC__) -# pragma GCC diagnostic pop -#elif defined(_MSC_VER ) -# pragma warning( pop ) -#endif - -#endif // optional_USES_STD_OPTIONAL - -#endif // NONSTD_OPTIONAL_LITE_HPP diff --git a/ndn-cxx/encoding/nfd-constants.hpp b/ndn-cxx/encoding/nfd-constants.hpp index 686f4c89..6b3389fb 100644 --- a/ndn-cxx/encoding/nfd-constants.hpp +++ b/ndn-cxx/encoding/nfd-constants.hpp @@ -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). * @@ -22,7 +22,9 @@ #ifndef NDN_CXX_ENCODING_NFD_CONSTANTS_HPP #define NDN_CXX_ENCODING_NFD_CONSTANTS_HPP -#include "ndn-cxx/detail/common.hpp" +#include +#include +#include namespace ndn { namespace nfd { diff --git a/ndn-cxx/encoding/tlv.hpp b/ndn-cxx/encoding/tlv.hpp index 35a46e47..4513d134 100644 --- a/ndn-cxx/encoding/tlv.hpp +++ b/ndn-cxx/encoding/tlv.hpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -168,10 +169,10 @@ isCriticalType(uint32_t type) noexcept * @brief Read VAR-NUMBER in NDN-TLV encoding. * @tparam Iterator an iterator or pointer that dereferences to uint8_t or compatible type * - * @param [inout] begin Begin of the buffer, will be incremented to point to the first byte after + * @param[in,out] begin Begin of the buffer, will be incremented to point to the first byte after * the read VAR-NUMBER - * @param [in] end End of the buffer - * @param [out] number Read VAR-NUMBER + * @param[in] end End of the buffer + * @param[out] number Read VAR-NUMBER * * @return true if number was successfully read from input, false otherwise */ @@ -183,10 +184,10 @@ readVarNumber(Iterator& begin, Iterator end, uint64_t& number) noexcept; * @brief Read TLV-TYPE. * @tparam Iterator an iterator or pointer that dereferences to uint8_t or compatible type * - * @param [inout] begin Begin of the buffer, will be incremented to point to the first byte after + * @param[in,out] begin Begin of the buffer, will be incremented to point to the first byte after * the read TLV-TYPE - * @param [in] end End of the buffer - * @param [out] type Read TLV-TYPE + * @param[in] end End of the buffer + * @param[out] type Read TLV-TYPE * * @return true if TLV-TYPE was successfully read from input, false otherwise * @note This function is largely equivalent to readVarNumber(), except that it returns false if @@ -200,9 +201,9 @@ readType(Iterator& begin, Iterator end, uint32_t& type) noexcept; * @brief Read VAR-NUMBER in NDN-TLV encoding. * @tparam Iterator an iterator or pointer that dereferences to uint8_t or compatible type * - * @param [inout] begin Begin of the buffer, will be incremented to point to the first byte after + * @param[in,out] begin Begin of the buffer, will be incremented to point to the first byte after * the read VAR-NUMBER - * @param [in] end End of the buffer + * @param[in] end End of the buffer * * @throw tlv::Error VAR-NUMBER cannot be read */ @@ -214,9 +215,9 @@ readVarNumber(Iterator& begin, Iterator end); * @brief Read TLV-TYPE. * @tparam Iterator an iterator or pointer that dereferences to uint8_t or compatible type * - * @param [inout] begin Begin of the buffer, will be incremented to point to the first byte after + * @param[in,out] begin Begin of the buffer, will be incremented to point to the first byte after * the read TLV-TYPE - * @param [in] end End of the buffer + * @param[in] end End of the buffer * * @throw tlv::Error TLV-TYPE cannot be read * @note This function is largely equivalent to readVarNumber(), except that it throws if @@ -243,10 +244,10 @@ writeVarNumber(std::ostream& os, uint64_t number); * @brief Read a NonNegativeInteger in NDN-TLV encoding. * @tparam Iterator an iterator or pointer that dereferences to uint8_t or compatible type * - * @param [in] size size of the NonNegativeInteger - * @param [inout] begin Begin of the buffer, will be incremented to point to the first byte after + * @param[in] size size of the NonNegativeInteger + * @param[in,out] begin Begin of the buffer, will be incremented to point to the first byte after * the read NonNegativeInteger - * @param [in] end End of the buffer + * @param[in] end End of the buffer * * @throw tlv::Error number cannot be read * @note How many bytes to read is directly controlled by \p size, which can be either 1, 2, 4, or 8. diff --git a/ndn-cxx/face.cpp b/ndn-cxx/face.cpp index 4a197011..b73039e1 100644 --- a/ndn-cxx/face.cpp +++ b/ndn-cxx/face.cpp @@ -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). * @@ -23,7 +23,6 @@ #include "ndn-cxx/encoding/tlv.hpp" #include "ndn-cxx/impl/face-impl.hpp" #include "ndn-cxx/net/face-uri.hpp" -#include "ndn-cxx/security/signing-helpers.hpp" #include "ndn-cxx/util/config-file.hpp" #include "ndn-cxx/util/scope.hpp" #include "ndn-cxx/util/time.hpp" @@ -252,7 +251,7 @@ Face::registerPrefix(const Name& prefix, nfd::CommandOptions options; options.setSigningInfo(signingInfo); - auto id = m_impl->registerPrefix(prefix, onSuccess, onFailure, flags, options, nullopt, nullptr); + auto id = m_impl->registerPrefix(prefix, onSuccess, onFailure, flags, options, std::nullopt, nullptr); return RegisteredPrefixHandle(m_impl, id); } diff --git a/ndn-cxx/impl/common-pch.hpp b/ndn-cxx/impl/common-pch.hpp index eea42874..539d977c 100644 --- a/ndn-cxx/impl/common-pch.hpp +++ b/ndn-cxx/impl/common-pch.hpp @@ -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). * @@ -30,7 +30,9 @@ // STL headers to precompile #include #include +#include #include +#include #include #include #include diff --git a/ndn-cxx/impl/face-impl.hpp b/ndn-cxx/impl/face-impl.hpp index 86ccb9ed..750e8042 100644 --- a/ndn-cxx/impl/face-impl.hpp +++ b/ndn-cxx/impl/face-impl.hpp @@ -154,17 +154,17 @@ public: // consumer /** * @return A Nack to be sent to the forwarder, or nullopt if no Nack should be sent. */ - optional + std::optional nackPendingInterests(const lp::Nack& nack) { - optional outNack; + std::optional outNack; m_pendingInterestTable.removeIf([&] (PendingInterest& entry) { if (!nack.getInterest().matchesInterest(*entry.getInterest())) { return false; } NDN_LOG_DEBUG(" nacking " << *entry.getInterest() << " from " << entry.getOrigin()); - optional outNack1 = entry.recordNack(nack); + auto outNack1 = entry.recordNack(nack); if (!outNack1) { return false; } @@ -234,7 +234,7 @@ public: // producer putNack(const lp::Nack& nack) { NDN_LOG_DEBUG(" outNack = nackPendingInterests(nack); + auto outNack = nackPendingInterests(nack); if (!outNack) { return; } @@ -255,8 +255,10 @@ public: // prefix registration registerPrefix(const Name& prefix, const RegisterPrefixSuccessCallback& onSuccess, const RegisterPrefixFailureCallback& onFailure, - uint64_t flags, const nfd::CommandOptions& options, - const optional& filter, const InterestCallback& onInterest) + uint64_t flags, + const nfd::CommandOptions& options, + const std::optional& filter, + const InterestCallback& onInterest) { NDN_LOG_INFO("registering prefix: " << prefix); auto id = m_registeredPrefixTable.allocateId(); diff --git a/ndn-cxx/impl/pending-interest.hpp b/ndn-cxx/impl/pending-interest.hpp index 1f88fdb7..6e36ba65 100644 --- a/ndn-cxx/impl/pending-interest.hpp +++ b/ndn-cxx/impl/pending-interest.hpp @@ -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,7 +114,7 @@ public: * @return Least severe Nack if all destinations where the Interest was forwarded have Nacked; * otherwise, @c nullopt. */ - optional + std::optional recordNack(const lp::Nack& nack) { --m_nNotNacked; @@ -124,7 +124,7 @@ public: m_leastSevereNack = nack; } - return m_nNotNacked > 0 ? nullopt : m_leastSevereNack; + return m_nNotNacked > 0 ? std::nullopt : m_leastSevereNack; } /** @@ -180,7 +180,7 @@ private: TimeoutCallback m_timeoutCallback; scheduler::ScopedEventId m_timeoutEvent; int m_nNotNacked = 0; ///< number of Interest destinations that have not Nacked - optional m_leastSevereNack; + std::optional m_leastSevereNack; }; } // namespace ndn diff --git a/ndn-cxx/ims/in-memory-storage.hpp b/ndn-cxx/ims/in-memory-storage.hpp index 0855e613..67fd76dc 100644 --- a/ndn-cxx/ims/in-memory-storage.hpp +++ b/ndn-cxx/ims/in-memory-storage.hpp @@ -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). * @@ -25,6 +25,7 @@ #include "ndn-cxx/ims/in-memory-storage-entry.hpp" #include +#include #include #include diff --git a/ndn-cxx/interest.cpp b/ndn-cxx/interest.cpp index 345d60bf..cd802cda 100644 --- a/ndn-cxx/interest.cpp +++ b/ndn-cxx/interest.cpp @@ -411,7 +411,7 @@ Interest::getNonce() const } Interest& -Interest::setNonce(optional nonce) +Interest::setNonce(std::optional nonce) { if (nonce != m_nonce) { m_nonce = nonce; @@ -448,7 +448,7 @@ Interest::setInterestLifetime(time::milliseconds lifetime) } Interest& -Interest::setHopLimit(optional hopLimit) +Interest::setHopLimit(std::optional hopLimit) { if (hopLimit != m_hopLimit) { m_hopLimit = hopLimit; @@ -527,14 +527,14 @@ Interest::isSigned() const noexcept m_name[-1].type() == tlv::ParametersSha256DigestComponent; } -optional +std::optional Interest::getSignatureInfo() const { auto blockIt = findFirstParameter(tlv::InterestSignatureInfo); if (blockIt != m_parameters.end()) { - return make_optional(*blockIt, SignatureInfo::Type::Interest); + return std::make_optional(*blockIt, SignatureInfo::Type::Interest); } - return nullopt; + return std::nullopt; } Interest& diff --git a/ndn-cxx/interest.hpp b/ndn-cxx/interest.hpp index 9777c146..d8ef0ea8 100644 --- a/ndn-cxx/interest.hpp +++ b/ndn-cxx/interest.hpp @@ -256,7 +256,7 @@ public: // element access * Use `setNonce(nullopt)` to remove any nonce from the Interest. */ Interest& - setNonce(optional nonce); + setNonce(std::optional nonce); /** * @brief Change nonce value. @@ -286,7 +286,7 @@ public: // element access /** * @brief Get the %Interest's hop limit. */ - optional + std::optional getHopLimit() const noexcept { return m_hopLimit; @@ -298,7 +298,7 @@ public: // element access * Use `setHopLimit(nullopt)` to remove any hop limit from the Interest. */ Interest& - setHopLimit(optional hopLimit); + setHopLimit(std::optional hopLimit); /** * @brief Return whether this Interest has any `ApplicationParameters` element. @@ -388,7 +388,7 @@ public: // element access * @brief Get the `InterestSignatureInfo` element. * @retval nullopt The element is not present. */ - optional + std::optional getSignatureInfo() const; /** @@ -494,9 +494,9 @@ private: Name m_name; std::vector m_forwardingHint; - mutable optional m_nonce; + mutable std::optional m_nonce; time::milliseconds m_interestLifetime = DEFAULT_INTEREST_LIFETIME; - optional m_hopLimit; + std::optional m_hopLimit; bool m_canBePrefix = false; bool m_mustBeFresh = false; diff --git a/ndn-cxx/lp/prefix-announcement-header.cpp b/ndn-cxx/lp/prefix-announcement-header.cpp index 8761be1e..3c5de4d7 100644 --- a/ndn-cxx/lp/prefix-announcement-header.cpp +++ b/ndn-cxx/lp/prefix-announcement-header.cpp @@ -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). * @@ -35,7 +35,7 @@ PrefixAnnouncementHeader::PrefixAnnouncementHeader(const Block& block) PrefixAnnouncementHeader::PrefixAnnouncementHeader(PrefixAnnouncement prefixAnn) : m_prefixAnn(std::move(prefixAnn)) { - if (m_prefixAnn->getData() == nullopt) { + if (!m_prefixAnn->getData()) { NDN_THROW(Error("PrefixAnnouncement does not contain Data")); } } @@ -44,7 +44,7 @@ template size_t PrefixAnnouncementHeader::wireEncode(EncodingImpl& encoder) const { - if (m_prefixAnn == nullopt) { + if (!m_prefixAnn) { NDN_THROW(Error("PrefixAnnouncementHeader does not contain a PrefixAnnouncement")); } diff --git a/ndn-cxx/lp/prefix-announcement-header.hpp b/ndn-cxx/lp/prefix-announcement-header.hpp index a316ee47..59e4cc98 100644 --- a/ndn-cxx/lp/prefix-announcement-header.hpp +++ b/ndn-cxx/lp/prefix-announcement-header.hpp @@ -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,14 +61,14 @@ public: void wireDecode(const Block& wire); - const optional& + const std::optional& getPrefixAnn() const { return m_prefixAnn; } private: - optional m_prefixAnn; + std::optional m_prefixAnn; }; NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(PrefixAnnouncementHeader); diff --git a/ndn-cxx/meta-info.cpp b/ndn-cxx/meta-info.cpp index 2d646919..f95b69d9 100644 --- a/ndn-cxx/meta-info.cpp +++ b/ndn-cxx/meta-info.cpp @@ -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). * @@ -63,7 +63,7 @@ MetaInfo::setFreshnessPeriod(time::milliseconds freshnessPeriod) } MetaInfo& -MetaInfo::setFinalBlock(optional finalBlockId) +MetaInfo::setFinalBlock(std::optional finalBlockId) { m_wire.reset(); m_finalBlockId = std::move(finalBlockId); @@ -215,7 +215,7 @@ MetaInfo::wireDecode(const Block& wire) ++val; } else { - m_finalBlockId = nullopt; + m_finalBlockId = std::nullopt; } // AppMetaInfo (if any) diff --git a/ndn-cxx/meta-info.hpp b/ndn-cxx/meta-info.hpp index ff8a1fe2..f2dd6997 100644 --- a/ndn-cxx/meta-info.hpp +++ b/ndn-cxx/meta-info.hpp @@ -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). * @@ -25,10 +25,10 @@ #include "ndn-cxx/name-component.hpp" #include "ndn-cxx/encoding/block.hpp" #include "ndn-cxx/encoding/encoding-buffer.hpp" -#include "ndn-cxx/util/optional.hpp" #include "ndn-cxx/util/time.hpp" #include +#include namespace ndn { @@ -118,18 +118,20 @@ public: // getter/setter MetaInfo& setFreshnessPeriod(time::milliseconds freshnessPeriod); - /** @brief Return the value of `FinalBlockId`. + /** + * @brief Return the value of `FinalBlockId`. */ - const optional& + const std::optional& getFinalBlock() const { return m_finalBlockId; } - /** @brief Set `FinalBlockId`. + /** + * @brief Set `FinalBlockId`. */ MetaInfo& - setFinalBlock(optional finalBlockId); + setFinalBlock(std::optional finalBlockId); public: // app-defined MetaInfo items /** @@ -195,7 +197,7 @@ public: // app-defined MetaInfo items private: uint32_t m_type; time::milliseconds m_freshnessPeriod; - optional m_finalBlockId; + std::optional m_finalBlockId; std::list m_appMetaInfo; mutable Block m_wire; diff --git a/ndn-cxx/metadata-object.cpp b/ndn-cxx/metadata-object.cpp index b764abaa..46c67d37 100644 --- a/ndn-cxx/metadata-object.cpp +++ b/ndn-cxx/metadata-object.cpp @@ -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). * @@ -53,7 +53,7 @@ Data MetadataObject::makeData(Name discoveryInterestName, KeyChain& keyChain, const ndn::security::SigningInfo& si, - optional version, + std::optional version, time::milliseconds freshnessPeriod) const { if (discoveryInterestName.empty() || discoveryInterestName[-1] != getKeywordComponent()) { diff --git a/ndn-cxx/metadata-object.hpp b/ndn-cxx/metadata-object.hpp index 6ad674af..0d9617b7 100644 --- a/ndn-cxx/metadata-object.hpp +++ b/ndn-cxx/metadata-object.hpp @@ -83,7 +83,7 @@ public: makeData(Name discoveryInterestName, KeyChain& keyChain, const ndn::security::SigningInfo& si = security::SigningInfo(), - optional version = nullopt, + std::optional version = std::nullopt, time::milliseconds freshnessPeriod = 10_ms) const; /** diff --git a/ndn-cxx/mgmt/nfd/face-query-filter.cpp b/ndn-cxx/mgmt/nfd/face-query-filter.cpp index a0f8e19d..39264fa4 100644 --- a/ndn-cxx/mgmt/nfd/face-query-filter.cpp +++ b/ndn-cxx/mgmt/nfd/face-query-filter.cpp @@ -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). * @@ -119,7 +119,7 @@ FaceQueryFilter::wireDecode(const Block& block) ++val; } else { - m_faceId = nullopt; + m_faceId = std::nullopt; } if (val != m_wire.elements_end() && val->type() == tlv::nfd::UriScheme) { @@ -151,7 +151,7 @@ FaceQueryFilter::wireDecode(const Block& block) ++val; } else { - m_faceScope = nullopt; + m_faceScope = std::nullopt; } if (val != m_wire.elements_end() && val->type() == tlv::nfd::FacePersistency) { @@ -159,7 +159,7 @@ FaceQueryFilter::wireDecode(const Block& block) ++val; } else { - m_facePersistency = nullopt; + m_facePersistency = std::nullopt; } if (val != m_wire.elements_end() && val->type() == tlv::nfd::LinkType) { @@ -167,7 +167,7 @@ FaceQueryFilter::wireDecode(const Block& block) ++val; } else { - m_linkType = nullopt; + m_linkType = std::nullopt; } } @@ -195,7 +195,7 @@ FaceQueryFilter& FaceQueryFilter::unsetFaceId() { m_wire.reset(); - m_faceId = nullopt; + m_faceId = std::nullopt; return *this; } @@ -253,7 +253,7 @@ FaceQueryFilter& FaceQueryFilter::unsetFaceScope() { m_wire.reset(); - m_faceScope = nullopt; + m_faceScope = std::nullopt; return *this; } @@ -269,7 +269,7 @@ FaceQueryFilter& FaceQueryFilter::unsetFacePersistency() { m_wire.reset(); - m_facePersistency = nullopt; + m_facePersistency = std::nullopt; return *this; } @@ -285,7 +285,7 @@ FaceQueryFilter& FaceQueryFilter::unsetLinkType() { m_wire.reset(); - m_linkType = nullopt; + m_linkType = std::nullopt; return *this; } diff --git a/ndn-cxx/mgmt/nfd/face-query-filter.hpp b/ndn-cxx/mgmt/nfd/face-query-filter.hpp index 7bff9aab..65de800c 100644 --- a/ndn-cxx/mgmt/nfd/face-query-filter.hpp +++ b/ndn-cxx/mgmt/nfd/face-query-filter.hpp @@ -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). * @@ -24,7 +24,8 @@ #include "ndn-cxx/encoding/block.hpp" #include "ndn-cxx/encoding/nfd-constants.hpp" -#include "ndn-cxx/util/optional.hpp" + +#include namespace ndn { namespace nfd { @@ -204,13 +205,13 @@ public: // getters & setters unsetLinkType(); private: - optional m_faceId; + std::optional m_faceId; std::string m_uriScheme; std::string m_remoteUri; std::string m_localUri; - optional m_faceScope; - optional m_facePersistency; - optional m_linkType; + std::optional m_faceScope; + std::optional m_facePersistency; + std::optional m_linkType; mutable Block m_wire; }; diff --git a/ndn-cxx/mgmt/nfd/face-status.cpp b/ndn-cxx/mgmt/nfd/face-status.cpp index 8727b403..a9b1c002 100644 --- a/ndn-cxx/mgmt/nfd/face-status.cpp +++ b/ndn-cxx/mgmt/nfd/face-status.cpp @@ -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). * @@ -148,7 +148,7 @@ FaceStatus::wireDecode(const Block& block) ++val; } else { - m_expirationPeriod = nullopt; + m_expirationPeriod = std::nullopt; } if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceScope) { @@ -180,7 +180,7 @@ FaceStatus::wireDecode(const Block& block) ++val; } else { - m_baseCongestionMarkingInterval = nullopt; + m_baseCongestionMarkingInterval = std::nullopt; } if (val != m_wire.elements_end() && val->type() == tlv::nfd::DefaultCongestionThreshold) { @@ -188,7 +188,7 @@ FaceStatus::wireDecode(const Block& block) ++val; } else { - m_defaultCongestionThreshold = nullopt; + m_defaultCongestionThreshold = std::nullopt; } if (val != m_wire.elements_end() && val->type() == tlv::nfd::Mtu) { @@ -196,7 +196,7 @@ FaceStatus::wireDecode(const Block& block) ++val; } else { - m_mtu = nullopt; + m_mtu = std::nullopt; } if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInInterests) { @@ -284,7 +284,7 @@ FaceStatus& FaceStatus::unsetExpirationPeriod() { m_wire.reset(); - m_expirationPeriod = nullopt; + m_expirationPeriod = std::nullopt; return *this; } @@ -300,7 +300,7 @@ FaceStatus& FaceStatus::unsetBaseCongestionMarkingInterval() { m_wire.reset(); - m_baseCongestionMarkingInterval = nullopt; + m_baseCongestionMarkingInterval = std::nullopt; return *this; } @@ -316,7 +316,7 @@ FaceStatus& FaceStatus::unsetDefaultCongestionThreshold() { m_wire.reset(); - m_defaultCongestionThreshold = nullopt; + m_defaultCongestionThreshold = std::nullopt; return *this; } @@ -332,7 +332,7 @@ FaceStatus& FaceStatus::unsetMtu() { m_wire.reset(); - m_mtu = nullopt; + m_mtu = std::nullopt; return *this; } diff --git a/ndn-cxx/mgmt/nfd/face-status.hpp b/ndn-cxx/mgmt/nfd/face-status.hpp index 8d0e59c1..893634bc 100644 --- a/ndn-cxx/mgmt/nfd/face-status.hpp +++ b/ndn-cxx/mgmt/nfd/face-status.hpp @@ -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). * @@ -23,9 +23,10 @@ #define NDN_CXX_MGMT_NFD_FACE_STATUS_HPP #include "ndn-cxx/mgmt/nfd/face-traits.hpp" -#include "ndn-cxx/util/optional.hpp" #include "ndn-cxx/util/time.hpp" +#include + namespace ndn { namespace nfd { @@ -220,10 +221,10 @@ public: // getters & setters setNOutBytes(uint64_t nOutBytes); private: - optional m_expirationPeriod; - optional m_baseCongestionMarkingInterval; - optional m_defaultCongestionThreshold; - optional m_mtu; + std::optional m_expirationPeriod; + std::optional m_baseCongestionMarkingInterval; + std::optional m_defaultCongestionThreshold; + std::optional m_mtu; uint64_t m_nInInterests; uint64_t m_nInData; uint64_t m_nInNacks; diff --git a/ndn-cxx/mgmt/nfd/rib-entry.cpp b/ndn-cxx/mgmt/nfd/rib-entry.cpp index a3551d0c..0356f68e 100644 --- a/ndn-cxx/mgmt/nfd/rib-entry.cpp +++ b/ndn-cxx/mgmt/nfd/rib-entry.cpp @@ -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). * @@ -94,7 +94,7 @@ Route::setExpirationPeriod(time::milliseconds expirationPeriod) Route& Route::unsetExpirationPeriod() { - m_expirationPeriod = nullopt; + m_expirationPeriod = std::nullopt; m_wire.reset(); return *this; } @@ -185,7 +185,7 @@ Route::wireDecode(const Block& block) ++val; } else { - m_expirationPeriod = nullopt; + m_expirationPeriod = std::nullopt; } } diff --git a/ndn-cxx/mgmt/nfd/rib-entry.hpp b/ndn-cxx/mgmt/nfd/rib-entry.hpp index 066bbab5..c91946f3 100644 --- a/ndn-cxx/mgmt/nfd/rib-entry.hpp +++ b/ndn-cxx/mgmt/nfd/rib-entry.hpp @@ -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 @@ private: RouteOrigin m_origin; uint64_t m_cost; uint64_t m_flags; - optional m_expirationPeriod; + std::optional m_expirationPeriod; mutable Block m_wire; }; diff --git a/ndn-cxx/name.cpp b/ndn-cxx/name.cpp index 89662811..a72bd8a5 100644 --- a/ndn-cxx/name.cpp +++ b/ndn-cxx/name.cpp @@ -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). * @@ -227,13 +227,13 @@ Name::set(ssize_t i, Component&& component) } Name& -Name::appendVersion(const optional& version) +Name::appendVersion(const std::optional& version) { return append(Component::fromVersion(version.value_or(time::toUnixTimestamp(time::system_clock::now()).count()))); } Name& -Name::appendTimestamp(const optional& timestamp) +Name::appendTimestamp(const std::optional& timestamp) { return append(Component::fromTimestamp(timestamp.value_or(time::system_clock::now()))); } diff --git a/ndn-cxx/name.hpp b/ndn-cxx/name.hpp index 297c1efc..4786bc70 100644 --- a/ndn-cxx/name.hpp +++ b/ndn-cxx/name.hpp @@ -23,9 +23,9 @@ #define NDN_CXX_NAME_HPP #include "ndn-cxx/name-component.hpp" -#include "ndn-cxx/util/optional.hpp" #include +#include namespace ndn { @@ -447,7 +447,7 @@ public: // modifiers * https://named-data.net/publications/techreports/ndn-tr-22-3-ndn-memo-naming-conventions/ */ Name& - appendVersion(const optional& version = nullopt); + appendVersion(const std::optional& version = std::nullopt); /** * @brief Append a timestamp component. @@ -457,7 +457,7 @@ public: // modifiers * https://named-data.net/publications/techreports/ndn-tr-22-3-ndn-memo-naming-conventions/ */ Name& - appendTimestamp(const optional& timestamp = nullopt); + appendTimestamp(const std::optional& timestamp = std::nullopt); /** * @brief Append a sequence number component. diff --git a/ndn-cxx/net/impl/link-type-helper-osx.mm b/ndn-cxx/net/impl/link-type-helper-osx.mm index 048a7808..75122591 100644 --- a/ndn-cxx/net/impl/link-type-helper-osx.mm +++ b/ndn-cxx/net/impl/link-type-helper-osx.mm @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2013-2018 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). * @@ -20,6 +20,7 @@ */ #include "ndn-cxx/net/impl/link-type-helper.hpp" +#include "ndn-cxx/detail/config.hpp" #ifndef NDN_CXX_HAVE_OSX_FRAMEWORKS #error "This file should not be compiled ..." diff --git a/ndn-cxx/net/impl/link-type-helper.hpp b/ndn-cxx/net/impl/link-type-helper.hpp index de4dfc65..e5bdc23b 100644 --- a/ndn-cxx/net/impl/link-type-helper.hpp +++ b/ndn-cxx/net/impl/link-type-helper.hpp @@ -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). * @@ -24,6 +24,8 @@ #include "ndn-cxx/encoding/nfd-constants.hpp" +#include + namespace ndn { namespace net { namespace detail { diff --git a/ndn-cxx/net/impl/netlink-message.hpp b/ndn-cxx/net/impl/netlink-message.hpp index dc80320b..ba888563 100644 --- a/ndn-cxx/net/impl/netlink-message.hpp +++ b/ndn-cxx/net/impl/netlink-message.hpp @@ -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). * @@ -26,7 +26,6 @@ #include "ndn-cxx/detail/common.hpp" #include "ndn-cxx/net/ethernet.hpp" -#include "ndn-cxx/util/optional.hpp" #ifndef NDN_CXX_HAVE_NETLINK #error "This file should not be included ..." @@ -38,6 +37,7 @@ #include #include +#include #include @@ -227,12 +227,12 @@ public: } template - optional + std::optional getAttributeByType(uint16_t attrType) const { auto it = m_attrs.find(attrType); if (it == m_attrs.end()) - return nullopt; + return std::nullopt; return convertAttrValue(getAttributeValue(it->second), getAttributeValueLength(it->second), @@ -261,48 +261,48 @@ private: } template - static std::enable_if_t::value, optional> + static std::enable_if_t::value, std::optional> convertAttrValue(const uint8_t* val, size_t len, AttrValueTypeTag) { if (len < sizeof(Integral)) - return nullopt; + return std::nullopt; Integral i; std::memcpy(&i, val, sizeof(Integral)); return i; } - static optional + static std::optional convertAttrValue(const uint8_t* val, size_t len, AttrValueTypeTag) { auto str = reinterpret_cast(val); if (::strnlen(str, len) >= len) - return nullopt; + return std::nullopt; - return std::string(str); + return std::make_optional(str); } - static optional + static std::optional convertAttrValue(const uint8_t* val, size_t len, AttrValueTypeTag) { if (len < ethernet::ADDR_LEN) - return nullopt; + return std::nullopt; - return ethernet::Address(val); + return std::make_optional(val); } template static std::enable_if_t::value || std::is_same::value, - optional> + std::optional> convertAttrValue(const uint8_t* val, size_t len, AttrValueTypeTag) { typename IpAddress::bytes_type bytes; if (len < bytes.size()) - return nullopt; + return std::nullopt; std::copy_n(val, bytes.size(), bytes.begin()); - return IpAddress(bytes); + return std::make_optional(bytes); } private: diff --git a/ndn-cxx/prefix-announcement.cpp b/ndn-cxx/prefix-announcement.cpp index d5a00494..decb314c 100644 --- a/ndn-cxx/prefix-announcement.cpp +++ b/ndn-cxx/prefix-announcement.cpp @@ -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). * @@ -68,7 +68,7 @@ PrefixAnnouncement::PrefixAnnouncement(Data data) const Data& PrefixAnnouncement::toData(KeyChain& keyChain, const ndn::security::SigningInfo& si, - optional version) const + std::optional version) const { if (!m_data) { Name dataName = m_announcedName; @@ -112,7 +112,7 @@ PrefixAnnouncement::setExpiration(time::milliseconds expiration) } PrefixAnnouncement& -PrefixAnnouncement::setValidityPeriod(optional validity) +PrefixAnnouncement::setValidityPeriod(std::optional validity) { m_data.reset(); m_validity = std::move(validity); diff --git a/ndn-cxx/prefix-announcement.hpp b/ndn-cxx/prefix-announcement.hpp index ed9ea0d4..11c29bdc 100644 --- a/ndn-cxx/prefix-announcement.hpp +++ b/ndn-cxx/prefix-announcement.hpp @@ -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). * @@ -58,7 +58,7 @@ public: /** \brief Get the Data representing the prefix announcement, if available. */ - const optional& + const std::optional& getData() const { return m_data; @@ -74,7 +74,7 @@ public: const Data& toData(KeyChain& keyChain, const ndn::security::SigningInfo& si = security::SigningInfo(), - optional version = nullopt) const; + std::optional version = std::nullopt) const; /** \brief Return announced name. */ @@ -107,7 +107,7 @@ public: /** \brief Return absolute validity period. */ - optional + std::optional getValidityPeriod() const { return m_validity; @@ -117,7 +117,7 @@ public: * \post getData() == nullopt */ PrefixAnnouncement& - setValidityPeriod(optional validity); + setValidityPeriod(std::optional validity); public: // static methods /** @@ -127,10 +127,10 @@ public: // static methods getKeywordComponent(); private: - mutable optional m_data; + mutable std::optional m_data; Name m_announcedName; time::milliseconds m_expiration = 0_ms; - optional m_validity; + std::optional m_validity; }; /** diff --git a/ndn-cxx/security/impl/openssl-helper.cpp b/ndn-cxx/security/impl/openssl-helper.cpp index c9c0cbf6..0b14fa1e 100644 --- a/ndn-cxx/security/impl/openssl-helper.cpp +++ b/ndn-cxx/security/impl/openssl-helper.cpp @@ -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). * @@ -21,6 +21,8 @@ #include "ndn-cxx/security/impl/openssl-helper.hpp" +#include + namespace ndn { namespace security { namespace detail { diff --git a/ndn-cxx/security/key-chain.cpp b/ndn-cxx/security/key-chain.cpp index dd30d730..98b70803 100644 --- a/ndn-cxx/security/key-chain.cpp +++ b/ndn-cxx/security/key-chain.cpp @@ -733,7 +733,7 @@ KeyChain::prepareSignatureInfoWithIdentity(const SigningInfo& params, const pib: std::tuple KeyChain::prepareSignatureInfoWithKey(const SigningInfo& params, const pib::Key& key, - const optional& certName) + const std::optional& certName) { auto sigInfo = params.getSignatureInfo(); sigInfo.setSignatureType(getSignatureType(key.getKeyType(), params.getDigestAlgorithm())); diff --git a/ndn-cxx/security/key-chain.hpp b/ndn-cxx/security/key-chain.hpp index 5e2f31a9..1740bb01 100644 --- a/ndn-cxx/security/key-chain.hpp +++ b/ndn-cxx/security/key-chain.hpp @@ -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 @@ struct MakeCertificateOptions * * Default is deriving from current timestamp using the logic of Name::appendVersion() . */ - optional version; + std::optional version; /** * @brief Certificate packet FreshnessPeriod. @@ -70,7 +70,7 @@ struct MakeCertificateOptions * * Default is a ValidityPeriod from now until 365 days later. */ - optional validity; + std::optional validity; }; inline namespace v2 { @@ -498,7 +498,7 @@ private: // signing static std::tuple prepareSignatureInfoWithKey(const SigningInfo& params, const pib::Key& key, - const optional& certName = nullopt); + const std::optional& certName = std::nullopt); /** * @brief Generate and return a raw signature for the byte ranges in @p bufs using diff --git a/ndn-cxx/security/pib/impl/key-impl.cpp b/ndn-cxx/security/pib/impl/key-impl.cpp index f3080997..23b6303f 100644 --- a/ndn-cxx/security/pib/impl/key-impl.cpp +++ b/ndn-cxx/security/pib/impl/key-impl.cpp @@ -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 @@ KeyImpl::removeCertificate(const Name& certName) if (m_defaultCert && m_defaultCert->getName() == certName) { NDN_LOG_DEBUG("Removing default certificate " << certName); - m_defaultCert = nullopt; + m_defaultCert = std::nullopt; } m_certificates.remove(certName); } diff --git a/ndn-cxx/security/pib/impl/key-impl.hpp b/ndn-cxx/security/pib/impl/key-impl.hpp index 172d103c..b6d73c64 100644 --- a/ndn-cxx/security/pib/impl/key-impl.hpp +++ b/ndn-cxx/security/pib/impl/key-impl.hpp @@ -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). * @@ -131,7 +131,7 @@ private: const shared_ptr m_pib; CertificateContainer m_certificates; - mutable optional m_defaultCert; + mutable std::optional m_defaultCert; }; } // namespace detail diff --git a/ndn-cxx/security/pib/impl/pib-memory.hpp b/ndn-cxx/security/pib/impl/pib-memory.hpp index 74abea3b..a2e7abdf 100644 --- a/ndn-cxx/security/pib/impl/pib-memory.hpp +++ b/ndn-cxx/security/pib/impl/pib-memory.hpp @@ -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). * @@ -127,7 +127,7 @@ private: std::string m_tpmLocator; std::set m_identities; - optional m_defaultIdentity; + std::optional m_defaultIdentity; /// identity name => default key name std::map m_defaultKeys; diff --git a/ndn-cxx/security/validation-policy-signed-interest.cpp b/ndn-cxx/security/validation-policy-signed-interest.cpp index 3ddab059..efaf82a2 100644 --- a/ndn-cxx/security/validation-policy-signed-interest.cpp +++ b/ndn-cxx/security/validation-policy-signed-interest.cpp @@ -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,9 +142,9 @@ ValidationPolicySignedInterest::checkIncomingInterest(const shared_ptr timestamp, - optional seqNum, - optional nonce) + std::optional timestamp, + std::optional seqNum, + std::optional nonce) { // If key record exists, update last refreshed time. Otherwise, create new record. Container::nth_index<0>::type::iterator it; diff --git a/ndn-cxx/security/validation-policy-signed-interest.hpp b/ndn-cxx/security/validation-policy-signed-interest.hpp index a600c006..92365cd9 100644 --- a/ndn-cxx/security/validation-policy-signed-interest.hpp +++ b/ndn-cxx/security/validation-policy-signed-interest.hpp @@ -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). * @@ -158,9 +158,9 @@ private: void insertRecord(const Name& keyName, - optional timestamp, - optional seqNum, - optional nonce); + std::optional timestamp, + std::optional seqNum, + std::optional nonce); private: Options m_options; @@ -181,8 +181,8 @@ private: struct LastInterestRecord { LastInterestRecord(const Name& keyName, - optional timestamp, - optional seqNum) + std::optional timestamp, + std::optional seqNum) : keyName(keyName) , timestamp(timestamp) , seqNum(seqNum) @@ -191,8 +191,8 @@ private: } Name keyName; - optional timestamp; - optional seqNum; + std::optional timestamp; + std::optional seqNum; NonceContainer observedNonces; time::steady_clock::TimePoint lastRefreshed; }; diff --git a/ndn-cxx/security/validation-state.cpp b/ndn-cxx/security/validation-state.cpp index e917fbcd..6fa2c966 100644 --- a/ndn-cxx/security/validation-state.cpp +++ b/ndn-cxx/security/validation-state.cpp @@ -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). * @@ -92,7 +92,7 @@ DataValidationState::~DataValidationState() } void -DataValidationState::verifyOriginalPacket(const optional& trustedCert) +DataValidationState::verifyOriginalPacket(const std::optional& trustedCert) { if (verifySignature(m_data, trustedCert)) { NDN_LOG_TRACE_DEPTH("OK signature for data `" << m_data.getName() << "`"); @@ -145,7 +145,7 @@ InterestValidationState::~InterestValidationState() } void -InterestValidationState::verifyOriginalPacket(const optional& trustedCert) +InterestValidationState::verifyOriginalPacket(const std::optional& trustedCert) { if (verifySignature(m_interest, trustedCert)) { NDN_LOG_TRACE_DEPTH("OK signature for interest `" << m_interest.getName() << "`"); diff --git a/ndn-cxx/security/validation-state.hpp b/ndn-cxx/security/validation-state.hpp index 15ea8f1b..de169153 100644 --- a/ndn-cxx/security/validation-state.hpp +++ b/ndn-cxx/security/validation-state.hpp @@ -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). * @@ -106,12 +106,12 @@ private: // Interface intended to be used only by Validator class /** * @brief Verify signature of the original packet * - * @param trustCert The certificate that signs the original packet, nullopt if certificate is - * not needed for verification (e.g., sha256 digest or attribute based - * signature) + * @param trustedCert The certificate that signs the original packet, nullopt if certificate + * is not needed for verification (e.g., sha256 digest or attribute based + * signature) */ virtual void - verifyOriginalPacket(const optional& trustedCert) = 0; + verifyOriginalPacket(const std::optional& trustedCert) = 0; /** * @brief Call success callback of the original packet without signature validation @@ -191,7 +191,7 @@ public: private: void - verifyOriginalPacket(const optional& trustedCert) final; + verifyOriginalPacket(const std::optional& trustedCert) final; void bypassValidation() final; @@ -243,7 +243,7 @@ public: private: void - verifyOriginalPacket(const optional& trustedCert) final; + verifyOriginalPacket(const std::optional& trustedCert) final; void bypassValidation() final; diff --git a/ndn-cxx/security/validator.cpp b/ndn-cxx/security/validator.cpp index 99d1a6f4..fd9817f3 100644 --- a/ndn-cxx/security/validator.cpp +++ b/ndn-cxx/security/validator.cpp @@ -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). * @@ -129,7 +129,7 @@ Validator::requestCertificate(const shared_ptr& certRequest, } if (certRequest->interest.getName() == SigningInfo::getDigestSha256Identity()) { - state->verifyOriginalPacket(nullopt); + state->verifyOriginalPacket(std::nullopt); return; } diff --git a/ndn-cxx/security/verification-helpers.cpp b/ndn-cxx/security/verification-helpers.cpp index 553b45ba..0a339f38 100644 --- a/ndn-cxx/security/verification-helpers.cpp +++ b/ndn-cxx/security/verification-helpers.cpp @@ -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). * @@ -216,7 +216,7 @@ verifySignature(const Interest& interest, const pib::Key& key) } bool -verifySignature(const Data& data, const optional& cert) +verifySignature(const Data& data, const std::optional& cert) { auto parsed = parse(data); if (cert) { @@ -232,7 +232,7 @@ verifySignature(const Data& data, const optional& cert) } bool -verifySignature(const Interest& interest, const optional& cert) +verifySignature(const Interest& interest, const std::optional& cert) { auto parsed = parse(interest); if (cert) { diff --git a/ndn-cxx/security/verification-helpers.hpp b/ndn-cxx/security/verification-helpers.hpp index 26cc824e..ee8c9ec8 100644 --- a/ndn-cxx/security/verification-helpers.hpp +++ b/ndn-cxx/security/verification-helpers.hpp @@ -108,7 +108,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) */ [[nodiscard]] bool -verifySignature(const Data& data, const optional& cert); +verifySignature(const Data& data, const std::optional& cert); /** * @brief Verify @p interest using @p cert. @@ -117,7 +117,7 @@ verifySignature(const Data& data, const optional& cert); * If @p cert is nullptr, @p interest assumed to be self-verifiable (with digest or attributes) */ [[nodiscard]] bool -verifySignature(const Interest& interest, const optional& cert); +verifySignature(const Interest& interest, const std::optional& cert); /** * @brief Verify @p data using @p tpm and @p keyName with the @p digestAlgorithm. diff --git a/ndn-cxx/signature-info.cpp b/ndn-cxx/signature-info.cpp index fb062d48..0e8eed40 100644 --- a/ndn-cxx/signature-info.cpp +++ b/ndn-cxx/signature-info.cpp @@ -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). * @@ -37,7 +37,7 @@ static_assert(std::is_base_of::value, SignatureInfo::SignatureInfo() = default; -SignatureInfo::SignatureInfo(tlv::SignatureTypeValue type, optional keyLocator) +SignatureInfo::SignatureInfo(tlv::SignatureTypeValue type, std::optional keyLocator) : m_type(type) , m_keyLocator(std::move(keyLocator)) { @@ -117,7 +117,7 @@ void SignatureInfo::wireDecode(const Block& wire, SignatureInfo::Type type) { m_type = -1; - m_keyLocator = nullopt; + m_keyLocator = std::nullopt; m_otherTlvs.clear(); m_wire = wire; @@ -196,7 +196,7 @@ SignatureInfo::getKeyLocator() const } SignatureInfo& -SignatureInfo::setKeyLocator(optional keyLocator) +SignatureInfo::setKeyLocator(std::optional keyLocator) { if (keyLocator != m_keyLocator) { m_keyLocator = std::move(keyLocator); @@ -216,7 +216,7 @@ SignatureInfo::getValidityPeriod() const } SignatureInfo& -SignatureInfo::setValidityPeriod(optional validityPeriod) +SignatureInfo::setValidityPeriod(std::optional validityPeriod) { if (!validityPeriod) { removeCustomTlv(tlv::ValidityPeriod); @@ -227,18 +227,18 @@ SignatureInfo::setValidityPeriod(optional validityPeri return *this; } -optional> +std::optional> SignatureInfo::getNonce() const { auto it = findOtherTlv(tlv::SignatureNonce); if (it == m_otherTlvs.end()) { - return nullopt; + return std::nullopt; } return std::vector(it->value_begin(), it->value_end()); } SignatureInfo& -SignatureInfo::setNonce(optional> nonce) +SignatureInfo::setNonce(std::optional> nonce) { if (!nonce) { removeCustomTlv(tlv::SignatureNonce); @@ -249,18 +249,18 @@ SignatureInfo::setNonce(optional> nonce) return *this; } -optional +std::optional SignatureInfo::getTime() const { auto it = findOtherTlv(tlv::SignatureTime); if (it == m_otherTlvs.end()) { - return nullopt; + return std::nullopt; } return time::fromUnixTimestamp(time::milliseconds(readNonNegativeInteger(*it))); } SignatureInfo& -SignatureInfo::setTime(optional time) +SignatureInfo::setTime(std::optional time) { if (!time) { removeCustomTlv(tlv::SignatureTime); @@ -272,18 +272,18 @@ SignatureInfo::setTime(optional time) return *this; } -optional +std::optional SignatureInfo::getSeqNum() const { auto it = findOtherTlv(tlv::SignatureSeqNum); if (it == m_otherTlvs.end()) { - return nullopt; + return std::nullopt; } return readNonNegativeInteger(*it); } SignatureInfo& -SignatureInfo::setSeqNum(optional seqNum) +SignatureInfo::setSeqNum(std::optional seqNum) { if (!seqNum) { removeCustomTlv(tlv::SignatureSeqNum); @@ -294,12 +294,12 @@ SignatureInfo::setSeqNum(optional seqNum) return *this; } -optional +std::optional SignatureInfo::getCustomTlv(uint32_t type) const { auto it = findOtherTlv(type); if (it == m_otherTlvs.end()) { - return nullopt; + return std::nullopt; } return *it; } diff --git a/ndn-cxx/signature-info.hpp b/ndn-cxx/signature-info.hpp index afb3ff57..134bc469 100644 --- a/ndn-cxx/signature-info.hpp +++ b/ndn-cxx/signature-info.hpp @@ -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: /** @brief Create with the specified type and KeyLocator */ explicit - SignatureInfo(tlv::SignatureTypeValue type, optional keyLocator = nullopt); + SignatureInfo(tlv::SignatureTypeValue type, std::optional keyLocator = std::nullopt); /** @brief Create from wire encoding * @param wire Wire to decode from @@ -143,7 +143,7 @@ public: // field access * @return A reference to this SignatureInfo, to allow chaining. */ SignatureInfo& - setKeyLocator(optional keyLocator); + setKeyLocator(std::optional keyLocator); /** @brief Get the `ValidityPeriod` element. * @throw Error This SignatureInfo does not contain a ValidityPeriod @@ -158,12 +158,12 @@ public: // field access * @return A reference to this SignatureInfo, to allow chaining. */ SignatureInfo& - setValidityPeriod(optional validityPeriod); + setValidityPeriod(std::optional validityPeriod); /** @brief Get SignatureNonce * @retval nullopt SignatureNonce is not set */ - optional> + std::optional> getNonce() const; /** @brief Append or replace SignatureNonce @@ -173,12 +173,12 @@ public: // field access * @return A reference to this SignatureInfo, to allow chaining. */ SignatureInfo& - setNonce(optional> nonce); + setNonce(std::optional> nonce); /** @brief Get SignatureTime * @retval nullopt SignatureTime is not set */ - optional + std::optional getTime() const; /** @brief Append or replace SignatureTime @@ -188,12 +188,12 @@ public: // field access * @return A reference to this SignatureInfo, to allow chaining. */ SignatureInfo& - setTime(optional time = time::system_clock::now()); + setTime(std::optional time = time::system_clock::now()); /** @brief Get SignatureSeqNum * @retval nullopt SignatureSeqNum is not set */ - optional + std::optional getSeqNum() const; /** @brief Append or replace SignatureSeqNum @@ -203,13 +203,13 @@ public: // field access * @return A reference to this SignatureInfo, to allow chaining. */ SignatureInfo& - setSeqNum(optional seqNum); + setSeqNum(std::optional seqNum); /** @brief Get first custom TLV element with the specified TLV-TYPE * @param type TLV-TYPE of element to get * @retval nullopt No custom TLV elements with the specified TLV-TYPE exist */ - optional + std::optional getCustomTlv(uint32_t type) const; /** @brief Append an arbitrary TLV element to this SignatureInfo @@ -231,7 +231,7 @@ private: private: int32_t m_type = -1; - optional m_keyLocator; + std::optional m_keyLocator; std::vector m_otherTlvs; mutable Block m_wire; diff --git a/ndn-cxx/util/io.hpp b/ndn-cxx/util/io.hpp index 52c7814f..4eb321ba 100644 --- a/ndn-cxx/util/io.hpp +++ b/ndn-cxx/util/io.hpp @@ -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). * @@ -24,7 +24,6 @@ #include "ndn-cxx/encoding/block.hpp" #include "ndn-cxx/util/concepts.hpp" -#include "ndn-cxx/util/optional.hpp" #include diff --git a/ndn-cxx/util/optional.hpp b/ndn-cxx/util/optional.hpp deleted file mode 100644 index 9113eada..00000000 --- a/ndn-cxx/util/optional.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2013-2022 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 - * . - * - * See AUTHORS.md for complete list of ndn-cxx authors and contributors. - */ - -#ifndef NDN_CXX_UTIL_OPTIONAL_HPP -#define NDN_CXX_UTIL_OPTIONAL_HPP - -#define optional_CONFIG_SELECT_OPTIONAL optional_OPTIONAL_NONSTD -#define optional_CONFIG_NO_EXTENSIONS 1 -#include "ndn-cxx/detail/nonstd/optional-lite.hpp" - -namespace ndn { - -using ::nonstd::optional; -using ::nonstd::bad_optional_access; -using ::nonstd::nullopt; -using ::nonstd::nullopt_t; -using ::nonstd::make_optional; - -using ::nonstd::in_place; -using ::nonstd::in_place_t; - -} // namespace ndn - -#endif // NDN_CXX_UTIL_OPTIONAL_HPP diff --git a/ndn-cxx/util/time.hpp b/ndn-cxx/util/time.hpp index 7792faa1..b4ffd531 100644 --- a/ndn-cxx/util/time.hpp +++ b/ndn-cxx/util/time.hpp @@ -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). * @@ -27,6 +27,8 @@ #include #include +#include + namespace ndn { namespace time { diff --git a/tests/test-common.cpp b/tests/test-common.cpp index 70414063..b0d06ea0 100644 --- a/tests/test-common.cpp +++ b/tests/test-common.cpp @@ -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). * @@ -25,8 +25,8 @@ namespace ndn { namespace tests { shared_ptr -makeInterest(const Name& name, bool canBePrefix, optional lifetime, - optional nonce) +makeInterest(const Name& name, bool canBePrefix, std::optional lifetime, + std::optional nonce) { auto interest = std::make_shared(name); interest->setCanBePrefix(canBePrefix); diff --git a/tests/test-common.hpp b/tests/test-common.hpp index f7f58a39..7b74f35a 100644 --- a/tests/test-common.hpp +++ b/tests/test-common.hpp @@ -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). * @@ -35,8 +35,8 @@ namespace tests { */ shared_ptr makeInterest(const Name& name, bool canBePrefix = false, - optional lifetime = nullopt, - optional nonce = nullopt); + std::optional lifetime = std::nullopt, + std::optional nonce = std::nullopt); /** * \brief Create a Data with a null (i.e., empty) signature @@ -70,7 +70,7 @@ makeNack(Interest interest, lp::NackReason reason); /** * \brief Replace a name component in a packet - * \param[inout] pkt the packet + * \param[in,out] pkt the packet * \param index the index of the name component to replace * \param args arguments to name::Component constructor */ diff --git a/tests/unit/face.t.cpp b/tests/unit/face.t.cpp index 5fdfd1c3..0ee95b4c 100644 --- a/tests/unit/face.t.cpp +++ b/tests/unit/face.t.cpp @@ -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). * @@ -427,14 +427,14 @@ BOOST_AUTO_TEST_CASE(PutNack) BOOST_CHECK_EQUAL(face.sentNacks.size(), 0); - face.put(makeNack(*makeInterest("/unsolicited", false, nullopt, 18645250), + face.put(makeNack(*makeInterest("/unsolicited", false, std::nullopt, 18645250), lp::NackReason::NO_ROUTE)); advanceClocks(10_ms); BOOST_CHECK_EQUAL(face.sentNacks.size(), 0); // unsolicited Nack would not be sent - auto interest1 = makeInterest("/Hello/World", false, nullopt, 14247162); + auto interest1 = makeInterest("/Hello/World", false, std::nullopt, 14247162); face.receive(*interest1); - auto interest2 = makeInterest("/another/prefix", false, nullopt, 92203002); + auto interest2 = makeInterest("/another/prefix", false, std::nullopt, 92203002); face.receive(*interest2); advanceClocks(10_ms); @@ -465,7 +465,7 @@ BOOST_AUTO_TEST_CASE(PutMultipleNack) face.setInterestFilter("/", bind([&] { hasInterest2 = true; })); advanceClocks(10_ms); - auto interest = makeInterest("/A", false, nullopt, 14333271); + auto interest = makeInterest("/A", false, std::nullopt, 14333271); face.receive(*interest); advanceClocks(10_ms); BOOST_CHECK(hasInterest1); @@ -496,7 +496,7 @@ BOOST_AUTO_TEST_CASE(PutMultipleNackLoopback) face.setInterestFilter(InterestFilter("/").allowLoopback(false), bind([] { BOOST_ERROR("Unexpected Interest on second InterestFilter"); })); - auto interest = makeInterest("/A", false, nullopt, 28395852); + auto interest = makeInterest("/A", false, std::nullopt, 28395852); face.expressInterest(*interest, bind([] { BOOST_FAIL("Unexpected data"); }), [&] (const Interest&, const lp::Nack& nack) { diff --git a/tests/unit/interest.t.cpp b/tests/unit/interest.t.cpp index 9e71cfb9..684f0976 100644 --- a/tests/unit/interest.t.cpp +++ b/tests/unit/interest.t.cpp @@ -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). * @@ -57,11 +57,11 @@ BOOST_AUTO_TEST_CASE(DefaultConstructor) BOOST_CHECK_EQUAL(i.getForwardingHint().empty(), true); BOOST_CHECK_EQUAL(i.hasNonce(), false); BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); - BOOST_CHECK(i.getHopLimit() == nullopt); + BOOST_CHECK(i.getHopLimit() == std::nullopt); BOOST_CHECK_EQUAL(i.hasApplicationParameters(), false); BOOST_CHECK_EQUAL(i.getApplicationParameters().isValid(), false); BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true); - BOOST_CHECK(i.getSignatureInfo() == nullopt); + BOOST_CHECK(i.getSignatureInfo() == std::nullopt); BOOST_CHECK_EQUAL(i.getSignatureValue().isValid(), false); BOOST_CHECK_EQUAL(i.isSigned(), false); } @@ -96,10 +96,10 @@ BOOST_AUTO_TEST_CASE(Basic) BOOST_CHECK_EQUAL(i2.hasNonce(), true); BOOST_CHECK_EQUAL(i2.getNonce(), 0x01020304); BOOST_CHECK_EQUAL(i2.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); - BOOST_CHECK(i2.getHopLimit() == nullopt); + BOOST_CHECK(i2.getHopLimit() == std::nullopt); BOOST_CHECK_EQUAL(i2.hasApplicationParameters(), false); BOOST_CHECK_EQUAL(i2.getApplicationParameters().isValid(), false); - BOOST_CHECK(i2.getSignatureInfo() == nullopt); + BOOST_CHECK(i2.getSignatureInfo() == std::nullopt); BOOST_CHECK_EQUAL(i2.getSignatureValue().isValid(), false); BOOST_CHECK_EQUAL(i2.isSigned(), false); } @@ -140,10 +140,10 @@ BOOST_AUTO_TEST_CASE(WithParameters) BOOST_CHECK_EQUAL(i2.hasNonce(), true); BOOST_CHECK_EQUAL(i2.getNonce(), 0x1); BOOST_CHECK_EQUAL(i2.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); - BOOST_CHECK(i2.getHopLimit() == nullopt); + BOOST_CHECK(i2.getHopLimit() == std::nullopt); BOOST_CHECK_EQUAL(i2.hasApplicationParameters(), true); BOOST_CHECK_EQUAL(i2.getApplicationParameters(), "2404C0C1C2C3"_block); - BOOST_CHECK(i2.getSignatureInfo() == nullopt); + BOOST_CHECK(i2.getSignatureInfo() == std::nullopt); BOOST_CHECK_EQUAL(i2.getSignatureValue().isValid(), false); BOOST_CHECK_EQUAL(i2.isSigned(), false); } @@ -402,7 +402,7 @@ BOOST_AUTO_TEST_CASE(NameOnly) BOOST_CHECK_EQUAL(i.getForwardingHint().empty(), true); BOOST_CHECK_EQUAL(i.hasNonce(), false); BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); - BOOST_CHECK(i.getHopLimit() == nullopt); + BOOST_CHECK(i.getHopLimit() == std::nullopt); BOOST_CHECK_EQUAL(i.hasApplicationParameters(), false); BOOST_CHECK_EQUAL(i.getApplicationParameters().isValid(), false); @@ -422,7 +422,7 @@ BOOST_AUTO_TEST_CASE(NameCanBePrefix) BOOST_CHECK_EQUAL(i.getForwardingHint().empty(), true); BOOST_CHECK_EQUAL(i.hasNonce(), false); BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); - BOOST_CHECK(i.getHopLimit() == nullopt); + BOOST_CHECK(i.getHopLimit() == std::nullopt); BOOST_CHECK_EQUAL(i.hasApplicationParameters(), false); BOOST_CHECK_EQUAL(i.getApplicationParameters().isValid(), false); } @@ -789,7 +789,7 @@ BOOST_AUTO_TEST_CASE(SetNonce) BOOST_CHECK_EQUAL(i2.getNonce(), 2); BOOST_CHECK_EQUAL(i1.getNonce(), 1); // should not affect i1's Nonce (Bug #4168) - i2.setNonce(nullopt); + i2.setNonce(std::nullopt); BOOST_CHECK(!i2.hasNonce()); } @@ -852,11 +852,11 @@ BOOST_AUTO_TEST_CASE(SetInterestLifetime) BOOST_AUTO_TEST_CASE(SetHopLimit) { Interest i; - BOOST_CHECK(i.getHopLimit() == nullopt); + BOOST_CHECK(i.getHopLimit() == std::nullopt); i.setHopLimit(42); BOOST_CHECK(i.getHopLimit() == 42); - i.setHopLimit(nullopt); - BOOST_CHECK(i.getHopLimit() == nullopt); + i.setHopLimit(std::nullopt); + BOOST_CHECK(i.getHopLimit() == std::nullopt); } BOOST_AUTO_TEST_CASE(SetApplicationParameters) @@ -901,7 +901,7 @@ BOOST_AUTO_TEST_CASE(SetSignature) return e.what() == "InterestSignatureInfo must be present to set InterestSignatureValue"s; }); - BOOST_CHECK(i.getSignatureInfo() == nullopt); + BOOST_CHECK(i.getSignatureInfo() == std::nullopt); BOOST_CHECK_EQUAL(i.getSignatureValue().isValid(), false); BOOST_CHECK_EQUAL(i.isSigned(), false); @@ -1010,7 +1010,7 @@ BOOST_AUTO_TEST_CASE(ParametersSha256DigestComponent) BOOST_CHECK(i.getSignatureInfo() == si); i.unsetApplicationParameters(); // removes ParametersSha256DigestComponent and InterestSignatureInfo - BOOST_CHECK(i.getSignatureInfo() == nullopt); + BOOST_CHECK(i.getSignatureInfo() == std::nullopt); BOOST_CHECK_EQUAL(i.getSignatureValue().isValid(), false); BOOST_CHECK_EQUAL(i.getName(), "/A/B/C"); @@ -1157,7 +1157,7 @@ BOOST_AUTO_TEST_CASE(ToUri) i.setCanBePrefix(false); i.setMustBeFresh(false); - i.setHopLimit(nullopt); + i.setHopLimit(std::nullopt); i.setApplicationParameters("2402CAFE"_block); BOOST_CHECK_EQUAL(i.toUri(), "/foo/params-sha256=8621f5e8321f04104640c8d02877d7c5142cad6e203c5effda1783b1a0e476d6" diff --git a/tests/unit/meta-info.t.cpp b/tests/unit/meta-info.t.cpp index af8416af..19fa2d39 100644 --- a/tests/unit/meta-info.t.cpp +++ b/tests/unit/meta-info.t.cpp @@ -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). * @@ -20,7 +20,6 @@ */ #include "ndn-cxx/meta-info.hpp" -#include "ndn-cxx/data.hpp" #include "tests/boost-test.hpp" @@ -35,7 +34,7 @@ BOOST_AUTO_TEST_CASE(EncodeDecode) MetaInfo a("1406 type=180100 freshness=190100"_block); BOOST_CHECK_EQUAL(a.getType(), tlv::ContentType_Blob); BOOST_CHECK_EQUAL(a.getFreshnessPeriod(), 0_ms); - BOOST_CHECK(a.getFinalBlock() == nullopt); + BOOST_CHECK(a.getFinalBlock() == std::nullopt); MetaInfo b; BOOST_CHECK_NE(a.wireEncode(), b.wireEncode()); diff --git a/tests/unit/security/certificate-cache.t.cpp b/tests/unit/security/certificate-cache.t.cpp index 8c715ebe..51aa72b4 100644 --- a/tests/unit/security/certificate-cache.t.cpp +++ b/tests/unit/security/certificate-cache.t.cpp @@ -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). * @@ -43,7 +43,7 @@ public: } void - checkFindByInterest(const Name& name, bool canBePrefix, optional expected) const + checkFindByInterest(const Name& name, bool canBePrefix, std::optional expected) const { Interest interest(name); interest.setCanBePrefix(canBePrefix); @@ -95,10 +95,10 @@ BOOST_AUTO_TEST_CASE(FindByInterest) checkFindByInterest(cert.getIdentity(), true, cert); checkFindByInterest(cert.getKeyName(), true, cert); checkFindByInterest(cert.getName(), false, cert); - checkFindByInterest(Name(cert.getName()).appendVersion(), true, nullopt); + checkFindByInterest(Name(cert.getName()).appendVersion(), true, std::nullopt); advanceClocks(12_s); - checkFindByInterest(cert.getIdentity(), true, nullopt); + checkFindByInterest(cert.getIdentity(), true, std::nullopt); } BOOST_AUTO_TEST_SUITE_END() // TestCertificateCache diff --git a/tests/unit/security/certificate.t.cpp b/tests/unit/security/certificate.t.cpp index f113ca95..37243d6d 100644 --- a/tests/unit/security/certificate.t.cpp +++ b/tests/unit/security/certificate.t.cpp @@ -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). * @@ -366,7 +366,7 @@ Signature Information: sigInfo.removeCustomTlv(tlv::AdditionalDescription); sigInfo.addCustomTlv(makeStringBlock(tlv::ValidityPeriod, "malformed")); sigInfo.setSignatureType(tlv::DigestSha256); - sigInfo.setKeyLocator(nullopt); + sigInfo.setKeyLocator(std::nullopt); Certificate cert6(cert3); cert6.setSignatureInfo(sigInfo); BOOST_CHECK_EQUAL(boost::lexical_cast(cert6), expected6); diff --git a/tests/unit/security/key-chain.t.cpp b/tests/unit/security/key-chain.t.cpp index 98a07215..9bd97af6 100644 --- a/tests/unit/security/key-chain.t.cpp +++ b/tests/unit/security/key-chain.t.cpp @@ -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). * @@ -427,7 +427,7 @@ struct AsymmetricSigningBase : protected KeyChainFixture, protected PacketType const uint32_t expectedSigType = SignatureTypeTlvValue; const bool shouldHaveKeyLocator = true; - const optional expectedKeyLocator = cert.getName(); + const std::optional expectedKeyLocator = cert.getName(); bool verify(const SigningInfo&) const @@ -504,7 +504,7 @@ struct HmacSigning : protected KeyChainFixture, protected PacketType const uint32_t expectedSigType = SignatureTypeTlvValue; const bool shouldHaveKeyLocator = true; - const optional expectedKeyLocator = nullopt; // don't check KeyLocator value + const std::optional expectedKeyLocator = std::nullopt; // don't check KeyLocator value bool verify(const SigningInfo& si) const @@ -524,12 +524,12 @@ struct Sha256Signing : protected KeyChainFixture, protected PacketType const uint32_t expectedSigType = tlv::DigestSha256; const bool shouldHaveKeyLocator = false; - const optional expectedKeyLocator = nullopt; + const std::optional expectedKeyLocator = std::nullopt; bool verify(const SigningInfo&) const { - return verifySignature(this->packet, nullopt); + return verifySignature(this->packet, std::nullopt); } }; @@ -591,7 +591,8 @@ public: } void - checkKeyLocatorName(const Certificate& cert, const optional& klName = nullopt) const + checkKeyLocatorName(const Certificate& cert, + const std::optional& klName = std::nullopt) const { auto kl = cert.getKeyLocator(); if (!kl.has_value()) { diff --git a/tests/unit/security/trust-anchor-container.t.cpp b/tests/unit/security/trust-anchor-container.t.cpp index 19d6867c..09825db2 100644 --- a/tests/unit/security/trust-anchor-container.t.cpp +++ b/tests/unit/security/trust-anchor-container.t.cpp @@ -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). * @@ -20,7 +20,6 @@ */ #include "ndn-cxx/security/trust-anchor-container.hpp" -#include "ndn-cxx/util/io.hpp" #include "tests/boost-test.hpp" #include "tests/key-chain-fixture.hpp" @@ -61,7 +60,7 @@ public: } void - checkFindByInterest(const Name& name, bool canBePrefix, optional expected) const + checkFindByInterest(const Name& name, bool canBePrefix, std::optional expected) const { Interest interest(name); interest.setCanBePrefix(canBePrefix); @@ -172,7 +171,7 @@ BOOST_AUTO_TEST_CASE(FindByInterest) checkFindByInterest(identity1.getName().getPrefix(-1), true, cert1); checkFindByInterest(cert1.getKeyName(), true, cert1); checkFindByInterest(cert1.getName(), false, cert1); - checkFindByInterest(Name(identity1.getName()).appendVersion(), true, nullopt); + checkFindByInterest(Name(identity1.getName()).appendVersion(), true, std::nullopt); auto makeIdentity1Cert = [=] (const std::string& issuerId) { auto key = identity1.getDefaultKey(); diff --git a/tests/unit/security/validation-policy-command-interest.t.cpp b/tests/unit/security/validation-policy-command-interest.t.cpp index 604c60d9..971b5091 100644 --- a/tests/unit/security/validation-policy-command-interest.t.cpp +++ b/tests/unit/security/validation-policy-command-interest.t.cpp @@ -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). * @@ -64,16 +64,16 @@ class ValidationPolicyCommandInterestFixture { protected: Interest - makeCommandInterest(const Identity& identity, SignedInterestFormat format = SignedInterestFormat::V02) + makeCommandInterest(const Identity& id, SignedInterestFormat format = SignedInterestFormat::V02) { - Name name = identity.getName(); + Name name = id.getName(); name.append("CMD"); switch (format) { case SignedInterestFormat::V02: - return m_signer.makeCommandInterest(name, signingByIdentity(identity)); + return m_signer.makeCommandInterest(name, signingByIdentity(id)); case SignedInterestFormat::V03: { Interest interest(name); - m_signer.makeSignedInterest(interest, signingByIdentity(identity)); + m_signer.makeSignedInterest(interest, signingByIdentity(id)); return interest; } } @@ -198,7 +198,7 @@ BOOST_AUTO_TEST_CASE(BadTimestampV03) { auto i1 = makeCommandInterest(identity, SignedInterestFormat::V03); auto si = i1.getSignatureInfo().value(); - si.setTime(nullopt); + si.setTime(std::nullopt); i1.setSignatureInfo(si); VALIDATE_FAILURE(i1, "Should fail (timestamp is missing)"); BOOST_TEST(lastError.getCode() == ValidationError::POLICY_ERROR); @@ -218,7 +218,7 @@ BOOST_AUTO_TEST_CASE(MissingKeyLocatorV03) { auto i1 = makeCommandInterest(identity, SignedInterestFormat::V03); auto si = i1.getSignatureInfo().value(); - si.setKeyLocator(nullopt); + si.setKeyLocator(std::nullopt); i1.setSignatureInfo(si); VALIDATE_FAILURE(i1, "Should fail (missing KeyLocator)"); BOOST_TEST(lastError.getCode() == ValidationError::INVALID_KEY_LOCATOR); diff --git a/tests/unit/security/validator-fixture.hpp b/tests/unit/security/validator-fixture.hpp index d8d357fc..7e1e0b55 100644 --- a/tests/unit/security/validator-fixture.hpp +++ b/tests/unit/security/validator-fixture.hpp @@ -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). * @@ -158,7 +158,7 @@ public: private: void - verifyOriginalPacket(const optional&) override + verifyOriginalPacket(const std::optional&) override { // do nothing } diff --git a/tests/unit/security/verification-helpers.t.cpp b/tests/unit/security/verification-helpers.t.cpp index d3434c81..83d37da7 100644 --- a/tests/unit/security/verification-helpers.t.cpp +++ b/tests/unit/security/verification-helpers.t.cpp @@ -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). * @@ -632,21 +632,21 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(VerifyDigest, Dataset, DigestDatasets) Interest interestOldFormat(dataset.goodInterestOldFormat); Interest badSigInterestOldFormat(dataset.badSigInterestOldFormat); - BOOST_CHECK(verifySignature(data, nullopt)); - BOOST_CHECK(verifySignature(interest, nullopt)); - BOOST_CHECK(verifySignature(interestOldFormat, nullopt)); + BOOST_CHECK(verifySignature(data, std::nullopt)); + BOOST_CHECK(verifySignature(interest, std::nullopt)); + BOOST_CHECK(verifySignature(interestOldFormat, std::nullopt)); - BOOST_CHECK(!verifySignature(badSigData, nullopt)); - BOOST_CHECK(!verifySignature(badSigInterest, nullopt)); - BOOST_CHECK(!verifySignature(badSigInterestOldFormat, nullopt)); + BOOST_CHECK(!verifySignature(badSigData, std::nullopt)); + BOOST_CHECK(!verifySignature(badSigInterest, std::nullopt)); + BOOST_CHECK(!verifySignature(badSigInterestOldFormat, std::nullopt)); Data unsignedData("/some/data"); Interest unsignedInterest1("/some/interest/with/several/name/components"); Interest unsignedInterest2("/interest-with-one-name-component"); - BOOST_CHECK(!verifySignature(unsignedData, nullopt)); - BOOST_CHECK(!verifySignature(unsignedInterest1, nullopt)); - BOOST_CHECK(!verifySignature(unsignedInterest2, nullopt)); + BOOST_CHECK(!verifySignature(unsignedData, std::nullopt)); + BOOST_CHECK(!verifySignature(unsignedInterest1, std::nullopt)); + BOOST_CHECK(!verifySignature(unsignedInterest2, std::nullopt)); } const uint8_t sha256DataUnrecognizedElements[] = { @@ -673,8 +673,8 @@ BOOST_AUTO_TEST_CASE(VerifyWithUnrecognizedElements) // Bug #4583 Data data(Block{sha256DataUnrecognizedElements}); Interest interest(Block{sha256InterestUnrecognizedElements}); - BOOST_CHECK(verifySignature(data, nullopt)); - BOOST_CHECK(verifySignature(interest, nullopt)); + BOOST_CHECK(verifySignature(data, std::nullopt)); + BOOST_CHECK(verifySignature(interest, std::nullopt)); } BOOST_AUTO_TEST_SUITE_END() // TestVerificationHelpers diff --git a/tests/unit/signature-info.t.cpp b/tests/unit/signature-info.t.cpp index dff4241c..1257851a 100644 --- a/tests/unit/signature-info.t.cpp +++ b/tests/unit/signature-info.t.cpp @@ -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). * @@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE(KeyLocatorField) info.wireEncode(); BOOST_CHECK_EQUAL(info.hasWire(), true); - info.setKeyLocator(nullopt); + info.setKeyLocator(std::nullopt); BOOST_CHECK_EQUAL(info.hasKeyLocator(), false); BOOST_CHECK_THROW(info.getKeyLocator(), SignatureInfo::Error); BOOST_CHECK_EQUAL(info.hasWire(), false); @@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE(SignatureNonce) info.wireEncode(); BOOST_CHECK_EQUAL(info.hasWire(), true); - info.setNonce(nullopt); + info.setNonce(std::nullopt); BOOST_CHECK_EQUAL(info.hasWire(), false); BOOST_CHECK(!info.getNonce()); } @@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE(SignatureTime) info.wireEncode(); BOOST_CHECK_EQUAL(info.hasWire(), true); - info.setTime(nullopt); + info.setTime(std::nullopt); BOOST_CHECK_EQUAL(info.hasWire(), false); BOOST_CHECK(!info.getTime()); } @@ -176,7 +176,7 @@ BOOST_AUTO_TEST_CASE(SignatureSeqNum) info.wireEncode(); BOOST_CHECK_EQUAL(info.hasWire(), true); - info.setSeqNum(nullopt); + info.setSeqNum(std::nullopt); BOOST_CHECK_EQUAL(info.hasWire(), false); BOOST_CHECK(!info.getSeqNum()); } @@ -452,7 +452,7 @@ BOOST_AUTO_TEST_CASE(ValidityPeriod) info2.wireEncode(); BOOST_CHECK_EQUAL(info2.hasWire(), true); - info2.setValidityPeriod(nullopt); + info2.setValidityPeriod(std::nullopt); BOOST_CHECK_THROW(info2.getValidityPeriod(), SignatureInfo::Error); BOOST_CHECK_EQUAL(info2.hasWire(), false); }