Browse Source

Update ghc::filesystem and nonstd::optional

pull/966/head
Antonio SJ Musumeci 3 years ago
parent
commit
313aa2a1d3
  1. 4
      src/ghc/filesystem.hpp
  2. 36
      src/nonstd/optional.hpp

4
src/ghc/filesystem.hpp

@ -301,7 +301,7 @@
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// ghc::filesystem version in decimal (major * 10000 + minor * 100 + patch) // 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)) #if !defined(GHC_WITH_EXCEPTIONS) && (defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND))
#define GHC_WITH_EXCEPTIONS #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(); ec = detail::make_system_error();
return {static_cast<uintmax_t>(-1), static_cast<uintmax_t>(-1), static_cast<uintmax_t>(-1)}; return {static_cast<uintmax_t>(-1), static_cast<uintmax_t>(-1), static_cast<uintmax_t>(-1)};
} }
return {static_cast<uintmax_t>(sfs.f_blocks * sfs.f_frsize), static_cast<uintmax_t>(sfs.f_bfree * sfs.f_frsize), static_cast<uintmax_t>(sfs.f_bavail * sfs.f_frsize)};
return {static_cast<uintmax_t>(sfs.f_blocks) * static_cast<uintmax_t>(sfs.f_frsize), static_cast<uintmax_t>(sfs.f_bfree) * static_cast<uintmax_t>(sfs.f_frsize), static_cast<uintmax_t>(sfs.f_bavail) * static_cast<uintmax_t>(sfs.f_frsize)};
#endif #endif
} }

36
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 // https://github.com/martinmoene/optional-lite
// //
@ -12,7 +12,7 @@
#define NONSTD_OPTIONAL_LITE_HPP #define NONSTD_OPTIONAL_LITE_HPP
#define optional_lite_MAJOR 3 #define optional_lite_MAJOR 3
#define optional_lite_MINOR 4
#define optional_lite_MINOR 5
#define optional_lite_PATCH 0 #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_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): // Control presence of exception handling (try and auto discover):
#ifndef optional_CONFIG_NO_EXCEPTIONS #ifndef optional_CONFIG_NO_EXCEPTIONS
# if _MSC_VER
# if defined(_MSC_VER)
# include <cstddef> // for _HAS_EXCEPTIONS # include <cstddef> // for _HAS_EXCEPTIONS
# endif # endif
# if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || (_HAS_EXCEPTIONS) # if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || (_HAS_EXCEPTIONS)
@ -313,8 +313,8 @@ namespace nonstd {
#define optional_CPP14_000 (optional_CPP14_OR_GREATER) #define optional_CPP14_000 (optional_CPP14_OR_GREATER)
#define optional_CPP17_000 (optional_CPP17_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): // 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 ) )
@ -331,7 +331,8 @@ namespace nonstd {
#define optional_HAVE_IS_DEFAULT optional_CPP11_140 #define optional_HAVE_IS_DEFAULT optional_CPP11_140
#define optional_HAVE_NOEXCEPT optional_CPP11_140 #define optional_HAVE_NOEXCEPT optional_CPP11_140
#define optional_HAVE_NULLPTR optional_CPP11_100 #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 #define optional_HAVE_INITIALIZER_LIST optional_CPP11_140
// Presence of C++14 language features: // Presence of C++14 language features:
@ -405,6 +406,12 @@ namespace nonstd {
# define optional_refref_qual /*&&*/ # define optional_refref_qual /*&&*/
#endif #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: // additional includes:
#if optional_CONFIG_NO_EXCEPTIONS #if optional_CONFIG_NO_EXCEPTIONS
@ -917,6 +924,15 @@ public:
template< typename T> template< typename T>
class optional class optional
{ {
optional_static_assert(( !std::is_same<typename std::remove_cv<T>::type, nullopt_t>::value ),
"T in optional<T> must not be of type 'nullopt_t'.")
optional_static_assert(( !std::is_same<typename std::remove_cv<T>::type, in_place_t>::value ),
"T in optional<T> must not be of type 'in_place_t'.")
optional_static_assert(( std::is_object<T>::value && std::is_destructible<T>::value && !std::is_array<T>::value ),
"T in optional<T> must meet the Cpp17Destructible requirements.")
private: private:
template< typename > friend class optional; template< typename > friend class optional;
@ -1090,7 +1106,7 @@ public:
> >
optional_constexpr explicit optional( nonstd_lite_in_place_t(T), Args&&... args ) optional_constexpr explicit optional( nonstd_lite_in_place_t(T), Args&&... args )
: has_value_( true ) : has_value_( true )
, contained( T( std::forward<Args>(args)...) )
, contained( in_place, std::forward<Args>(args)... )
{} {}
// 7 (C++11) - in-place construct, initializer-list // 7 (C++11) - in-place construct, initializer-list
@ -1443,7 +1459,7 @@ public:
#endif #endif
#if optional_CPP11_OR_GREATER
#if optional_HAVE( REF_QUALIFIER )
template< typename U > template< typename U >
optional_constexpr value_type value_or( U && v ) const optional_ref_qual optional_constexpr value_type value_or( U && v ) const optional_ref_qual
@ -1454,7 +1470,11 @@ public:
template< typename U > template< typename U >
optional_constexpr14 value_type value_or( U && v ) optional_refref_qual 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<T>(std::forward<U>( v ) );
#else
return has_value() ? std::move( contained.value() ) : static_cast<T>(std::forward<U>( v ) ); return has_value() ? std::move( contained.value() ) : static_cast<T>(std::forward<U>( v ) );
#endif
} }
#else #else

Loading…
Cancel
Save