detail: update bundled copies of {optional,scope}-lite
optional-lite commit 36c5b877b2efa7201c49aef4d6eff5e6d7a59ec0
scope-lite commit 9794ec00059403aef6b5cd7eed008e98ae47a845
Change-Id: Ib1915df07eab35c01433889054650b128ec74c4d
diff --git a/ndn-cxx/detail/nonstd/optional-lite.hpp b/ndn-cxx/detail/nonstd/optional-lite.hpp
index b4fde93..2c9f122 100644
--- a/ndn-cxx/detail/nonstd/optional-lite.hpp
+++ b/ndn-cxx/detail/nonstd/optional-lite.hpp
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2014-2018 Martin Moene
+// Copyright (c) 2014-2021 Martin Moene
//
// https://github.com/martinmoene/optional-lite
//
@@ -12,7 +12,7 @@
#define NONSTD_OPTIONAL_LITE_HPP
#define optional_lite_MAJOR 3
-#define optional_lite_MINOR 4
+#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)
@@ -47,7 +47,7 @@
// Control presence of exception handling (try and auto discover):
#ifndef optional_CONFIG_NO_EXCEPTIONS
-# if _MSC_VER
+# if defined(_MSC_VER)
# include <cstddef> // for _HAS_EXCEPTIONS
# endif
# if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || (_HAS_EXCEPTIONS)
@@ -1106,7 +1106,7 @@
>
optional_constexpr explicit optional( nonstd_lite_in_place_t(T), Args&&... args )
: has_value_( true )
- , contained( T( std::forward<Args>(args)...) )
+ , contained( in_place, std::forward<Args>(args)... )
{}
// 7 (C++11) - in-place construct, initializer-list
diff --git a/ndn-cxx/detail/nonstd/scope-lite.hpp b/ndn-cxx/detail/nonstd/scope-lite.hpp
index 03699d3..aa8ce4c 100644
--- a/ndn-cxx/detail/nonstd/scope-lite.hpp
+++ b/ndn-cxx/detail/nonstd/scope-lite.hpp
@@ -13,7 +13,7 @@
#define NONSTD_SCOPE_LITE_HPP
#define scope_lite_MAJOR 0
-#define scope_lite_MINOR 1
+#define scope_lite_MINOR 2
#define scope_lite_PATCH 0
#define scope_lite_VERSION scope_STRINGIFY(scope_lite_MAJOR) "." scope_STRINGIFY(scope_lite_MINOR) "." scope_STRINGIFY(scope_lite_PATCH)
@@ -27,6 +27,20 @@
#define scope_SCOPE_NONSTD 1
#define scope_SCOPE_STD 2
+// tweak header support:
+
+#ifdef __has_include
+# if __has_include(<nonstd/scope.tweak.hpp>)
+# include <nonstd/scope.tweak.hpp>
+# endif
+#define scope_HAVE_TWEAK_HEADER 1
+#else
+#define scope_HAVE_TWEAK_HEADER 0
+//# pragma message("scope.hpp: Note: Tweak header not supported.")
+#endif
+
+// scope selection and configuration:
+
#if !defined( scope_CONFIG_SELECT_SCOPE )
# define scope_CONFIG_SELECT_SCOPE ( scope_HAVE_STD_SCOPE ? scope_SCOPE_STD : scope_SCOPE_NONSTD )
#endif
@@ -203,11 +217,14 @@
#define scope_HAVE_IS_COPY_CONSTRUCTIBLE scope_CPP11_110
#define scope_HAVE_IS_MOVE_CONSTRUCTIBLE scope_CPP11_110
#define scope_HAVE_IS_NOTHROW_CONSTRUCTIBLE scope_CPP11_110
+#define scope_HAVE_IS_NOTHROW_COPY_CONSTRUCTIBLE scope_CPP11_110
#define scope_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE scope_CPP11_110
#define scope_HAVE_IS_COPY_ASSIGNABLE scope_CPP11_110
#define scope_HAVE_IS_NOTHROW_ASSIGNABLE scope_CPP11_110
#define scope_HAVE_IS_NOTHROW_MOVE_ASSIGNABLE scope_CPP11_110
+#define scope_HAVE_REFERENCE_WRAPPER scope_CPP11_110
+
#define scope_HAVE_REMOVE_CV scope_CPP11_90
#define scope_HAVE_REMOVE_REFERENCE scope_CPP11_90
@@ -457,7 +474,6 @@
template< class T > struct remove_reference{ typedef T type; };
#endif
-
#if scope_HAVE( REFERENCE_WRAPPER )
using std::reference_wrapper;
#else
@@ -1225,14 +1241,11 @@
}
};
-template< typename Policy >
+template< typename Policy, typename Action >
class scope_guard : public Policy
{
public:
- typedef void (*Action)();
-
- template< typename Fn >
- scope_guard( Fn action )
+ scope_guard( Action action )
: Policy()
, action_( action )
{}
@@ -1255,25 +1268,25 @@
Action action_;
};
-class scope_exit : public scope_guard< on_exit_policy >
+template< typename Fn = void(*)() >
+class scope_exit : public scope_guard< on_exit_policy, Fn >
{
public:
- template< typename Fn >
- scope_exit( Fn action ) : scope_guard( action ) {}
+ scope_exit( Fn action ) : scope_guard<on_exit_policy, Fn>( action ) {}
};
-class scope_fail : public scope_guard< on_fail_policy >
+template< typename Fn = void(*)() >
+class scope_fail : public scope_guard< on_fail_policy, Fn >
{
public:
- template< typename Fn >
- scope_fail( Fn action ) : scope_guard( action ) {}
+ scope_fail( Fn action ) : scope_guard<on_fail_policy, Fn>( action ) {}
};
-class scope_success : public scope_guard< on_success_policy >
+template< typename Fn = void(*)() >
+class scope_success : public scope_guard< on_success_policy, Fn >
{
public:
- template< typename Fn >
- scope_success( Fn action ) : scope_guard( action ) {}
+ scope_success( Fn action ) : scope_guard<on_success_policy, Fn>( action ) {}
};
// unique_resource (C++98):
@@ -1380,21 +1393,21 @@
};
template< class EF >
-scope_exit make_scope_exit( EF action )
+scope_exit<EF> make_scope_exit( EF action )
{
- return scope_exit( action );
+ return scope_exit<EF>( action );
}
template< class EF >
-scope_fail make_scope_fail( EF action )
+scope_fail<EF> make_scope_fail( EF action )
{
- return scope_fail( action );
+ return scope_fail<EF>( action );
}
template< class EF >
-scope_success make_scope_success( EF action )
+scope_success<EF> make_scope_success( EF action )
{
- return scope_success( action );
+ return scope_success<EF>( action );
}
template< class R, class D, class S >