util: update bundled copies of {any,optional,variant}-lite
any-lite commit 56cdca9c94af84c6e643a05c9105cb1dc38c5d8c
optional-lite commit 5e8a82ac029aebfd2f5708f183a00eda2be132cc
variant-lite commit 1f79b88132687b0ab1efdcf6e4120724e813602b
Change-Id: I7149abedade21f91e673770169ab7cd6062f02c7
diff --git a/ndn-cxx/util/nonstd/any.hpp b/ndn-cxx/util/nonstd/any.hpp
index cf5071e..aaea3cc 100644
--- a/ndn-cxx/util/nonstd/any.hpp
+++ b/ndn-cxx/util/nonstd/any.hpp
@@ -12,7 +12,7 @@
#define NONSTD_ANY_LITE_HPP
#define any_lite_MAJOR 0
-#define any_lite_MINOR 1
+#define any_lite_MINOR 2
#define any_lite_PATCH 0
#define any_lite_VERSION any_STRINGIFY(any_lite_MAJOR) "." any_STRINGIFY(any_lite_MINOR) "." any_STRINGIFY(any_lite_PATCH)
@@ -183,16 +183,17 @@
// Compiler versions:
//
-// MSVC++ 6.0 _MSC_VER == 1200 (Visual Studio 6.0)
-// MSVC++ 7.0 _MSC_VER == 1300 (Visual Studio .NET 2002)
-// MSVC++ 7.1 _MSC_VER == 1310 (Visual Studio .NET 2003)
-// MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005)
-// MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008)
-// MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
-// MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012)
-// MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
-// MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
-// MSVC++ 14.1 _MSC_VER >= 1910 (Visual Studio 2017)
+// MSVC++ 6.0 _MSC_VER == 1200 any_COMPILER_MSVC_VERSION == 60 (Visual Studio 6.0)
+// MSVC++ 7.0 _MSC_VER == 1300 any_COMPILER_MSVC_VERSION == 70 (Visual Studio .NET 2002)
+// MSVC++ 7.1 _MSC_VER == 1310 any_COMPILER_MSVC_VERSION == 71 (Visual Studio .NET 2003)
+// MSVC++ 8.0 _MSC_VER == 1400 any_COMPILER_MSVC_VERSION == 80 (Visual Studio 2005)
+// MSVC++ 9.0 _MSC_VER == 1500 any_COMPILER_MSVC_VERSION == 90 (Visual Studio 2008)
+// MSVC++ 10.0 _MSC_VER == 1600 any_COMPILER_MSVC_VERSION == 100 (Visual Studio 2010)
+// MSVC++ 11.0 _MSC_VER == 1700 any_COMPILER_MSVC_VERSION == 110 (Visual Studio 2012)
+// MSVC++ 12.0 _MSC_VER == 1800 any_COMPILER_MSVC_VERSION == 120 (Visual Studio 2013)
+// MSVC++ 14.0 _MSC_VER == 1900 any_COMPILER_MSVC_VERSION == 140 (Visual Studio 2015)
+// MSVC++ 14.1 _MSC_VER >= 1910 any_COMPILER_MSVC_VERSION == 141 (Visual Studio 2017)
+// MSVC++ 14.2 _MSC_VER >= 1920 any_COMPILER_MSVC_VERSION == 142 (Visual Studio 2019)
#if defined(_MSC_VER ) && !defined(__clang__)
# define any_COMPILER_MSVC_VER (_MSC_VER )
@@ -324,7 +325,7 @@
template< bool B = (__VA_ARGS__), typename std::enable_if<B, int>::type = 0 >
#define any_REQUIRES_T(...) \
- , typename = typename std::enable_if< (__VA_ARGS__), nonstd::any_lite::detail::enabler >::type
+ , typename std::enable_if< (__VA_ARGS__), int >::type = 0
#define any_REQUIRES_R(R, ...) \
typename std::enable_if<__VA_ARGS__, R>::type
@@ -424,7 +425,7 @@
any_REQUIRES_T( ! std::is_same<T, any>::value )
>
any( ValueType && value ) any_noexcept
- : content( new holder<T>( std::move( value ) ) )
+ : content( new holder<T>( std::forward<ValueType>( value ) ) )
{}
template<
diff --git a/ndn-cxx/util/nonstd/optional.hpp b/ndn-cxx/util/nonstd/optional.hpp
index d05d1c5..133673a 100644
--- a/ndn-cxx/util/nonstd/optional.hpp
+++ b/ndn-cxx/util/nonstd/optional.hpp
@@ -12,8 +12,8 @@
#define NONSTD_OPTIONAL_LITE_HPP
#define optional_lite_MAJOR 3
-#define optional_lite_MINOR 1
-#define optional_lite_PATCH 1
+#define optional_lite_MINOR 2
+#define optional_lite_PATCH 0
#define optional_lite_VERSION optional_STRINGIFY(optional_lite_MAJOR) "." optional_STRINGIFY(optional_lite_MINOR) "." optional_STRINGIFY(optional_lite_PATCH)
@@ -227,16 +227,17 @@
// Compiler versions:
//
-// MSVC++ 6.0 _MSC_VER == 1200 (Visual Studio 6.0)
-// MSVC++ 7.0 _MSC_VER == 1300 (Visual Studio .NET 2002)
-// MSVC++ 7.1 _MSC_VER == 1310 (Visual Studio .NET 2003)
-// MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005)
-// MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008)
-// MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
-// MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012)
-// MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
-// MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
-// MSVC++ 14.1 _MSC_VER >= 1910 (Visual Studio 2017)
+// 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 )
@@ -292,6 +293,8 @@
#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_CPP11_140_490 ((optional_CPP11_OR_GREATER_ && optional_COMPILER_GNUC_VERSION >= 490) || (optional_COMPILER_MSVC_VER >= 1910))
+
#define optional_CPP14_000 (optional_CPP14_OR_GREATER)
#define optional_CPP17_000 (optional_CPP17_OR_GREATER)
@@ -301,7 +304,8 @@
#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
+#define optional_HAVE_REF_QUALIFIER optional_CPP11_140_490
+#define optional_HAVE_INITIALIZER_LIST optional_CPP11_140
// Presence of C++14 language features:
@@ -397,7 +401,7 @@
template< bool B = (__VA_ARGS__), typename std::enable_if<B, int>::type = 0 >
#define optional_REQUIRES_T(...) \
- , typename = typename std::enable_if< (__VA_ARGS__), nonstd::optional_lite::detail::enabler >::type
+ , typename std::enable_if< (__VA_ARGS__), int >::type = 0
#define optional_REQUIRES_R(R, ...) \
typename std::enable_if< (__VA_ARGS__), R>::type
@@ -428,6 +432,16 @@
template< typename T, typename F > struct conditional<false, T, F> { typedef F type; };
#endif // optional_HAVE_CONDITIONAL
+// gcc < 5:
+#if optional_CPP11_OR_GREATER
+#if optional_BETWEEN( optional_COMPILER_GNUC_VERSION, 1, 500 )
+ template< typename T > struct is_trivially_copy_constructible : std::true_type{};
+ template< typename T > struct is_trivially_move_constructible : std::true_type{};
+#else
+ using std::is_trivially_copy_constructible;
+ using std::is_trivially_move_constructible;
+#endif
+#endif
} // namespace std11
#if optional_CPP11_OR_GREATER
@@ -508,12 +522,6 @@
namespace detail {
-// for optional_REQUIRES_T
-
-#if optional_CPP11_OR_GREATER
-enum class enabler{};
-#endif
-
// C++11 emulation:
struct nulltype{};
@@ -743,7 +751,7 @@
return * value_ptr();
}
-#if optional_CPP11_OR_GREATER
+#if optional_HAVE( REF_QUALIFIER )
optional_nodiscard value_type const && value() const optional_refref_qual
{
@@ -861,13 +869,15 @@
{}
// 2 - copy-construct
- optional_constexpr14 optional( optional const & other
#if optional_CPP11_OR_GREATER
- optional_REQUIRES_A(
- true || std::is_copy_constructible<T>::value
- )
+ // template< typename U = T
+ // optional_REQUIRES_T(
+ // std::is_copy_constructible<U>::value
+ // || std11::is_trivially_copy_constructible<U>::value
+ // )
+ // >
#endif
- )
+ optional_constexpr14 optional( optional const & other )
: has_value_( other.has_value() )
{
if ( other.has_value() )
@@ -879,12 +889,15 @@
#if optional_CPP11_OR_GREATER
// 3 (C++11) - move-construct from optional
- optional_constexpr14 optional( optional && other
- optional_REQUIRES_A(
- true || std::is_move_constructible<T>::value
+ template< typename U = T
+ optional_REQUIRES_T(
+ std::is_move_constructible<U>::value
+ || std11::is_trivially_move_constructible<U>::value
)
- // NOLINTNEXTLINE( performance-noexcept-move-constructor )
- ) noexcept( std::is_nothrow_move_constructible<T>::value )
+ >
+ optional_constexpr14 optional( optional && other )
+ // NOLINTNEXTLINE( performance-noexcept-move-constructor )
+ noexcept( std::is_nothrow_move_constructible<T>::value )
: has_value_( other.has_value() )
{
if ( other.has_value() )
@@ -894,9 +907,8 @@
}
// 4a (C++11) - explicit converting copy-construct from optional
- template< typename U >
- explicit optional( optional<U> const & other
- optional_REQUIRES_A(
+ template< typename U
+ optional_REQUIRES_T(
std::is_constructible<T, U const &>::value
&& !std::is_constructible<T, optional<U> & >::value
&& !std::is_constructible<T, optional<U> && >::value
@@ -908,7 +920,8 @@
&& !std::is_convertible< optional<U> const &&, T>::value
&& !std::is_convertible< U const & , T>::value /*=> explicit */
)
- )
+ >
+ explicit optional( optional<U> const & other )
: has_value_( other.has_value() )
{
if ( other.has_value() )
@@ -919,11 +932,9 @@
#endif // optional_CPP11_OR_GREATER
// 4b (C++98 and later) - non-explicit converting copy-construct from optional
- template< typename U >
- // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions )
- optional( optional<U> const & other
+ template< typename U
#if optional_CPP11_OR_GREATER
- optional_REQUIRES_A(
+ optional_REQUIRES_T(
std::is_constructible<T, U const &>::value
&& !std::is_constructible<T, optional<U> & >::value
&& !std::is_constructible<T, optional<U> && >::value
@@ -936,7 +947,9 @@
&& 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<U> const & other )
: has_value_( other.has_value() )
{
if ( other.has_value() )
@@ -948,9 +961,8 @@
#if optional_CPP11_OR_GREATER
// 5a (C++11) - explicit converting move-construct from optional
- template< typename U >
- explicit optional( optional<U> && other
- optional_REQUIRES_A(
+ template< typename U
+ optional_REQUIRES_T(
std::is_constructible<T, U &&>::value
&& !std::is_constructible<T, optional<U> & >::value
&& !std::is_constructible<T, optional<U> && >::value
@@ -962,6 +974,8 @@
&& !std::is_convertible< optional<U> const &&, T>::value
&& !std::is_convertible< U &&, T>::value /*=> explicit */
)
+ >
+ explicit optional( optional<U> && other
)
: has_value_( other.has_value() )
{
@@ -972,10 +986,8 @@
}
// 5a (C++11) - non-explicit converting move-construct from optional
- template< typename U >
- // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions )
- optional( optional<U> && other
- optional_REQUIRES_A(
+ template< typename U
+ optional_REQUIRES_T(
std::is_constructible<T, U &&>::value
&& !std::is_constructible<T, optional<U> & >::value
&& !std::is_constructible<T, optional<U> && >::value
@@ -987,7 +999,9 @@
&& !std::is_convertible< optional<U> const &&, T>::value
&& std::is_convertible< U &&, T>::value /*=> non-explicit */
)
- )
+ >
+ // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions )
+ /*non-explicit*/ optional( optional<U> && other )
: has_value_( other.has_value() )
{
if ( other.has_value() )
@@ -1019,30 +1033,30 @@
{}
// 8a (C++11) - explicit move construct from value
- template< typename U = value_type >
- optional_constexpr explicit optional( U && value
- optional_REQUIRES_A(
+ template< typename U = T
+ optional_REQUIRES_T(
std::is_constructible<T, U&&>::value
&& !std::is_same<typename std20::remove_cvref<U>::type, nonstd_lite_in_place_t(U)>::value
&& !std::is_same<typename std20::remove_cvref<U>::type, optional<T>>::value
&& !std::is_convertible<U&&, T>::value /*=> explicit */
)
- )
+ >
+ optional_constexpr explicit optional( U && value )
: has_value_( true )
, contained( T{ std::forward<U>( value ) } )
{}
// 8b (C++11) - non-explicit move construct from value
- template< typename U = value_type >
- // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions )
- optional_constexpr optional( U && value
- optional_REQUIRES_A(
+ template< typename U = T
+ optional_REQUIRES_T(
std::is_constructible<T, U&&>::value
&& !std::is_same<typename std20::remove_cvref<U>::type, nonstd_lite_in_place_t(U)>::value
&& !std::is_same<typename std20::remove_cvref<U>::type, optional<T>>::value
&& std::is_convertible<U&&, T>::value /*=> non-explicit */
)
- )
+ >
+ // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions )
+ optional_constexpr /*non-explicit*/ optional( U && value )
: has_value_( true )
, contained( std::forward<U>( value ) )
{}
@@ -1283,7 +1297,7 @@
contained.value();
}
-#if optional_HAVE( REF_QUALIFIER ) && ( !optional_COMPILER_GNUC_VERSION || optional_COMPILER_GNUC_VERSION >= 490 )
+#if optional_HAVE( REF_QUALIFIER )
optional_constexpr value_type const && operator *() const optional_refref_qual
{
@@ -1659,7 +1673,10 @@
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;
diff --git a/ndn-cxx/util/nonstd/variant.hpp b/ndn-cxx/util/nonstd/variant.hpp
index f0e70b9..86a1d21 100644
--- a/ndn-cxx/util/nonstd/variant.hpp
+++ b/ndn-cxx/util/nonstd/variant.hpp
@@ -11,8 +11,8 @@
#define NONSTD_VARIANT_LITE_HPP
#define variant_lite_MAJOR 1
-#define variant_lite_MINOR 1
-#define variant_lite_PATCH 0
+#define variant_lite_MINOR 2
+#define variant_lite_PATCH 2
#define variant_lite_VERSION variant_STRINGIFY(variant_lite_MAJOR) "." variant_STRINGIFY(variant_lite_MINOR) "." variant_STRINGIFY(variant_lite_PATCH)
@@ -247,16 +247,17 @@
// Compiler versions:
//
-// MSVC++ 6.0 _MSC_VER == 1200 (Visual Studio 6.0)
-// MSVC++ 7.0 _MSC_VER == 1300 (Visual Studio .NET 2002)
-// MSVC++ 7.1 _MSC_VER == 1310 (Visual Studio .NET 2003)
-// MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005)
-// MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008)
-// MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
-// MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012)
-// MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
-// MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
-// MSVC++ 14.1 _MSC_VER >= 1910 (Visual Studio 2017)
+// MSVC++ 6.0 _MSC_VER == 1200 variant_COMPILER_MSVC_VERSION == 60 (Visual Studio 6.0)
+// MSVC++ 7.0 _MSC_VER == 1300 variant_COMPILER_MSVC_VERSION == 70 (Visual Studio .NET 2002)
+// MSVC++ 7.1 _MSC_VER == 1310 variant_COMPILER_MSVC_VERSION == 71 (Visual Studio .NET 2003)
+// MSVC++ 8.0 _MSC_VER == 1400 variant_COMPILER_MSVC_VERSION == 80 (Visual Studio 2005)
+// MSVC++ 9.0 _MSC_VER == 1500 variant_COMPILER_MSVC_VERSION == 90 (Visual Studio 2008)
+// MSVC++ 10.0 _MSC_VER == 1600 variant_COMPILER_MSVC_VERSION == 100 (Visual Studio 2010)
+// MSVC++ 11.0 _MSC_VER == 1700 variant_COMPILER_MSVC_VERSION == 110 (Visual Studio 2012)
+// MSVC++ 12.0 _MSC_VER == 1800 variant_COMPILER_MSVC_VERSION == 120 (Visual Studio 2013)
+// MSVC++ 14.0 _MSC_VER == 1900 variant_COMPILER_MSVC_VERSION == 140 (Visual Studio 2015)
+// MSVC++ 14.1 _MSC_VER >= 1910 variant_COMPILER_MSVC_VERSION == 141 (Visual Studio 2017)
+// MSVC++ 14.2 _MSC_VER >= 1920 variant_COMPILER_MSVC_VERSION == 142 (Visual Studio 2019)
#if defined(_MSC_VER ) && !defined(__clang__)
# define variant_COMPILER_MSVC_VER (_MSC_VER )
@@ -394,7 +395,7 @@
template< bool B = (__VA_ARGS__), typename std::enable_if<B, int>::type = 0 >
#define variant_REQUIRES_T(...) \
- , typename = typename std::enable_if< (__VA_ARGS__), nonstd::variants::detail::enabler >::type
+ , typename std::enable_if< (__VA_ARGS__), int >::type = 0
#define variant_REQUIRES_R(R, ...) \
typename std::enable_if< (__VA_ARGS__), R>::type
@@ -532,10 +533,6 @@
namespace detail {
-// for variant_REQUIRES_T():
-
-/*enum*/ class enabler{};
-
// typelist:
#define variant_TL1( T1 ) detail::typelist< T1, detail::nulltype >
@@ -1519,12 +1516,10 @@
template< class T >
T & get()
{
- const std::size_t i = index_of<T>();
-
#if variant_CONFIG_NO_EXCEPTIONS
- assert( i == index() );
+ assert( index_of<T>() == index() );
#else
- if ( i != index() )
+ if ( index_of<T>() != index() )
{
throw bad_variant_access();
}
@@ -1535,12 +1530,10 @@
template< class T >
T const & get() const
{
- const std::size_t i = index_of<T>();
-
#if variant_CONFIG_NO_EXCEPTIONS
- assert( i == index() );
+ assert( index_of<T>() == index() );
#else
- if ( i != index() )
+ if ( index_of<T>() != index() )
{
throw bad_variant_access();
}
@@ -1922,7 +1915,8 @@
template< typename Visitor, typename T >
static R apply(Visitor const&, T)
{
- return R();
+ // prevent default construction of a const reference, see issue #39:
+ std::terminate();
}
};
@@ -2109,7 +2103,8 @@
case 14: return apply_visitor<14>(v, arg);
case 15: return apply_visitor<15>(v, arg);
- default: return R();
+ // prevent default construction of a const reference, see issue #39:
+ default: std::terminate();
}
}
@@ -2383,7 +2378,7 @@
case 14: return nvd::hash( 14 ) ^ nvd::hash( get<14>( v ) );
case 15: return nvd::hash( 15 ) ^ nvd::hash( get<15>( v ) );
- default: return false;
+ default: return 0;
}
}
};