From 313aa2a1d30a15d60ba3caec1a3e21b0f9c6b3d5 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Thu, 30 Sep 2021 19:30:04 -0400 Subject: [PATCH] Update ghc::filesystem and nonstd::optional --- src/ghc/filesystem.hpp | 4 ++-- src/nonstd/optional.hpp | 40 ++++++++++++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/ghc/filesystem.hpp b/src/ghc/filesystem.hpp index 0705cf7f..4924c73c 100644 --- a/src/ghc/filesystem.hpp +++ b/src/ghc/filesystem.hpp @@ -301,7 +301,7 @@ //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ghc::filesystem version in decimal (major * 10000 + minor * 100 + patch) -#define GHC_FILESYSTEM_VERSION 10508L +#define GHC_FILESYSTEM_VERSION 10509L #if !defined(GHC_WITH_EXCEPTIONS) && (defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND)) #define GHC_WITH_EXCEPTIONS @@ -4875,7 +4875,7 @@ GHC_INLINE space_info space(const path& p, std::error_code& ec) noexcept ec = detail::make_system_error(); return {static_cast(-1), static_cast(-1), static_cast(-1)}; } - return {static_cast(sfs.f_blocks * sfs.f_frsize), static_cast(sfs.f_bfree * sfs.f_frsize), static_cast(sfs.f_bavail * sfs.f_frsize)}; + return {static_cast(sfs.f_blocks) * static_cast(sfs.f_frsize), static_cast(sfs.f_bfree) * static_cast(sfs.f_frsize), static_cast(sfs.f_bavail) * static_cast(sfs.f_frsize)}; #endif } diff --git a/src/nonstd/optional.hpp b/src/nonstd/optional.hpp index 8b371e5a..2c9f1224 100644 --- a/src/nonstd/optional.hpp +++ b/src/nonstd/optional.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 // for _HAS_EXCEPTIONS # endif # if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || (_HAS_EXCEPTIONS) @@ -313,11 +313,11 @@ namespace nonstd { #define optional_CPP14_000 (optional_CPP14_OR_GREATER) #define optional_CPP17_000 (optional_CPP17_OR_GREATER) -// gcc >= 4.9, msvc >= vc14.1 (vs17): -#define optional_CPP11_140_G490 ((optional_CPP11_OR_GREATER_ && optional_COMPILER_GNUC_VERSION >= 490) || (optional_COMPILER_MSVC_VER >= 1910)) +// 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 ) ) +#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 \ @@ -331,7 +331,8 @@ namespace nonstd { #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_G490 +#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: @@ -405,6 +406,12 @@ namespace nonstd { # 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 @@ -917,6 +924,15 @@ public: 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; @@ -925,7 +941,7 @@ private: public: typedef T value_type; - // x.x.3.1, constructors + // x.x.3.1, constructors // 1a - default construct optional_constexpr optional() optional_noexcept @@ -1090,7 +1106,7 @@ public: > optional_constexpr explicit optional( nonstd_lite_in_place_t(T), Args&&... args ) : has_value_( true ) - , contained( T( std::forward(args)...) ) + , contained( in_place, std::forward(args)... ) {} // 7 (C++11) - in-place construct, initializer-list @@ -1443,7 +1459,7 @@ public: #endif -#if optional_CPP11_OR_GREATER +#if optional_HAVE( REF_QUALIFIER ) template< typename U > optional_constexpr value_type value_or( U && v ) const optional_ref_qual @@ -1454,7 +1470,11 @@ public: 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