Comparing c++_v1_xcode_10_2_1 & llvm_libcxx_7_0_0
@@ -1,11 +1,14 @@
+ .DS_Store
+ CMakeLists.txt
__bit_reference
__bsd_locale_defaults.h
__bsd_locale_fallbacks.h
__config
+ __config_site.in
__debug
__errc
__functional_03
__functional_base
__functional_base_03
__hash_table
__libcpp_version
@@ -66,14 +69,15 @@
experimental/__memory
experimental/algorithm
experimental/any
experimental/chrono
experimental/coroutine
experimental/deque
experimental/dynarray
+ experimental/filesystem
experimental/forward_list
experimental/functional
experimental/iterator
experimental/list
experimental/map
experimental/memory_resource
experimental/numeric
@@ -92,14 +96,15 @@
experimental/unordered_set
experimental/utility
experimental/vector
ext
ext/__hash
ext/hash_map
ext/hash_set
+ filesystem
float.h
forward_list
fstream
functional
future
initializer_list
inttypes.h
@@ -1,42 +1,7 @@
- //===----------------------------------------------------------------------===//
- //
- // The LLVM Compiler Infrastructure
- //
- // This file is dual licensed under the MIT and the University of Illinois Open
- // Source Licenses. See LICENSE.TXT for details.
- //
- //===----------------------------------------------------------------------===//
-
- #ifndef _LIBCPP_CONFIG_SITE
- #define _LIBCPP_CONFIG_SITE
-
- /* #undef _LIBCPP_ABI_VERSION */
- /* #undef _LIBCPP_ABI_UNSTABLE */
- /* #undef _LIBCPP_ABI_FORCE_ITANIUM */
- /* #undef _LIBCPP_ABI_FORCE_MICROSOFT */
- #define _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
- /* #undef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE */
- /* #undef _LIBCPP_HAS_NO_STDIN */
- /* #undef _LIBCPP_HAS_NO_STDOUT */
- /* #undef _LIBCPP_HAS_NO_THREADS */
- /* #undef _LIBCPP_HAS_NO_MONOTONIC_CLOCK */
- /* #undef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS */
- /* #undef _LIBCPP_HAS_MUSL_LIBC */
- /* #undef _LIBCPP_HAS_THREAD_API_PTHREAD */
- /* #undef _LIBCPP_HAS_THREAD_API_EXTERNAL */
- /* #undef _LIBCPP_HAS_THREAD_API_WIN32 */
- /* #undef _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL */
- /* #undef _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS */
- /* #undef _LIBCPP_NO_VCRUNTIME */
- #define _LIBCPP_WARN_ON_DEPRECATED_EXPERIMENTAL_HEADER
-
-
-
- #endif // _LIBCPP_CONFIG_SITE
// -*- C++ -*-
//===--------------------------- __config ---------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
@@ -740,14 +705,20 @@
#define _LIBCPP_EXTERN_VIS _LIBCPP_DLL_VIS
#define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS
#define _LIBCPP_HIDDEN
#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
#define _LIBCPP_TEMPLATE_VIS
#define _LIBCPP_ENUM_VIS
+ #if defined(_LIBCPP_COMPILER_MSVC)
+ # define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
+ #else
+ # define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ ((__always_inline__))
+ #endif
+
#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
#ifndef _LIBCPP_HIDDEN
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
# else
#define _LIBCPP_HIDDEN
@@ -829,53 +800,41 @@
#if __has_attribute(internal_linkage)
# define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))
#else
# define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
#endif
- #if __has_attribute(exclude_from_explicit_instantiation)
- # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__))
- #else
- // Try to approximate the effect of exclude_from_explicit_instantiation
- // (which is that entities are not assumed to be provided by explicit
- // template instantitations in the dylib) by always inlining those entities.
- # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
- #endif
-
#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU
# ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
#define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
# else
#define _LIBCPP_HIDE_FROM_ABI_PER_TU 1
# endif
#endif
#ifndef _LIBCPP_HIDE_FROM_ABI
# if _LIBCPP_HIDE_FROM_ABI_PER_TU
#define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
# else
- #define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
+ #define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_ALWAYS_INLINE
# endif
#endif
- #ifdef _LIBCPP_BUILDING_LIBRARY
- # if _LIBCPP_ABI_VERSION > 1
- #define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
+ // Just so we can migrate to _LIBCPP_HIDE_FROM_ABI gradually.
+ #define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
+
+ #ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
+ # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+ #define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__))
# else
- #define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ #define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__always_inline__))
# endif
- #else
- # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
#endif
- // Just so we can migrate to the new macros gradually.
- #define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
- #define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI_AFTER_V1
-
#ifndef _LIBCPP_PREFERRED_OVERLOAD
# if __has_attribute(__enable_if__)
#define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
# endif
#endif
#ifndef _LIBCPP_HAS_NO_NOEXCEPT
@@ -1307,24 +1266,17 @@
// Define availability macros.
#if defined(_LIBCPP_USE_AVAILABILITY_APPLE)
# define _LIBCPP_AVAILABILITY_SHARED_MUTEX\
__attribute__((availability(macosx,strict,introduced=10.12))) \
__attribute__((availability(ios,strict,introduced=10.0))) \
__attribute__((availability(tvos,strict,introduced=10.0)))\
__attribute__((availability(watchos,strict,introduced=3.0)))
- # define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \
- __attribute__((availability(macosx,strict,introduced=10.14))) \
- __attribute__((availability(ios,strict,introduced=12.0))) \
- __attribute__((availability(tvos,strict,introduced=12.0)))\
- __attribute__((availability(watchos,strict,introduced=5.0)))
- # define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \
- _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
+ # define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((unavailable))
# define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH __attribute__((unavailable))
- # define _LIBCPP_AVAILABILITY_BAD_ANY_CAST\
- _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
+ # define _LIBCPP_AVAILABILITY_BAD_ANY_CAST __attribute__((unavailable))
# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \
__attribute__((availability(macosx,strict,introduced=10.12))) \
__attribute__((availability(ios,strict,introduced=10.0))) \
__attribute__((availability(tvos,strict,introduced=10.0)))\
__attribute__((availability(watchos,strict,introduced=3.0)))
# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE\
__attribute__((availability(macosx,strict,introduced=10.12))) \
@@ -1340,15 +1292,14 @@
__attribute__((availability(macosx,strict,introduced=10.9))) \
__attribute__((availability(ios,strict,introduced=7.0)))
# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \
__attribute__((availability(macosx,strict,introduced=10.9))) \
__attribute__((availability(ios,strict,introduced=7.0)))
#else
# define _LIBCPP_AVAILABILITY_SHARED_MUTEX
- # define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
# define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH
# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
# define _LIBCPP_AVAILABILITY_FUTURE_ERROR
# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
@@ -1357,25 +1308,19 @@
#endif
// Define availability that depends on _LIBCPP_NO_EXCEPTIONS.
#ifdef _LIBCPP_NO_EXCEPTIONS
# define _LIBCPP_AVAILABILITY_DYNARRAY
# define _LIBCPP_AVAILABILITY_FUTURE
# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
- # define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
- # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
#else
# define _LIBCPP_AVAILABILITY_DYNARRAY _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH
# define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR
# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST \
_LIBCPP_AVAILABILITY_BAD_ANY_CAST
- # define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS \
- _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
- # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS\
- _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
#endif
// Availability of stream API in the dylib got dropped and re-added. The
// extern template should effectively be available at:
//availability(macosx,introduced=10.9)
//availability(ios,introduced=7.0)
#if defined(_LIBCPP_USE_AVAILABILITY_APPLE) && \
@@ -31,14 +31,23 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Key, class _Tp>
struct __hash_value_type;
+ template <class _Key, class _Cp, class _Hash,
+ bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>
+ class __unordered_map_hasher;
+
+ template <class _Key, class _Cp, class _Pred,
+ bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value
+ >
+ class __unordered_map_equal;
+
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp>
struct __is_hash_value_type_imp : false_type {};
template <class _Key, class _Value>
struct __is_hash_value_type_imp<__hash_value_type<_Key, _Value>> : true_type {};
@@ -405,15 +414,15 @@
typedef typename _NodeTypes::__const_node_value_type_pointer pointer;
_LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT : __node_(nullptr) {
_LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
__hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT
: __node_(__x.__node_)
{
_LIBCPP_DEBUG_MODE(__get_db()->__iterator_copy(this, &__x));
}
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -858,40 +867,43 @@
struct __generic_container_node_destructor<__hash_node<_Tp, _VoidPtr>, _Alloc>
: __hash_node_destructor<_Alloc>
{
using __hash_node_destructor<_Alloc>::__hash_node_destructor;
};
#endif
- template <class _Key, class _Hash, class _Equal>
- struct __enforce_unordered_container_requirements {
#ifndef _LIBCPP_CXX03_LANG
+ template <class _Key, class _Hash, class _Equal, class _Alloc>
+ struct __diagnose_hash_table_helper {
+ static constexpr bool __trigger_diagnostics()
+ _LIBCPP_DIAGNOSE_WARNING(__check_hash_requirements<_Key, _Hash>::value
+ && !__invokable<_Hash const&, _Key const&>::value,
+ "the specified hash functor does not provide a const call operator")
+ _LIBCPP_DIAGNOSE_WARNING(is_copy_constructible<_Equal>::value
+ && !__invokable<_Equal const&, _Key const&, _Key const&>::value,
+ "the specified comparator type does not provide a const call operator")
+ {
static_assert(__check_hash_requirements<_Key, _Hash>::value,
- "the specified hash does not meet the Hash requirements");
+ "the specified hash does not meet the Hash requirements");
static_assert(is_copy_constructible<_Equal>::value,
- "the specified comparator is required to be copy constructible");
- #endif
- typedef int type;
+ "the specified comparator is required to be copy constructible");
+ return true;
+ }
};
- template <class _Key, class _Hash, class _Equal>
- #ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Equal const&, _Key const&, _Key const&>::value,
- "the specified comparator type does not provide a const call operator")
- _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Hash const&, _Key const&>::value,
- "the specified hash functor does not provide a const call operator")
- #endif
- typename __enforce_unordered_container_requirements<_Key, _Hash, _Equal>::type
- __diagnose_unordered_container_requirements(int);
-
- // This dummy overload is used so that the compiler won't emit a spurious
- // "no matching function for call to __diagnose_unordered_xxx" diagnostic
- // when the overload above causes a hard error.
- template <class _Key, class _Hash, class _Equal>
- int __diagnose_unordered_container_requirements(void*);
+ template <class _Key, class _Value, class _Hash, class _Equal, class _Alloc>
+ struct __diagnose_hash_table_helper<
+ __hash_value_type<_Key, _Value>,
+ __unordered_map_hasher<_Key, __hash_value_type<_Key, _Value>, _Hash>,
+ __unordered_map_equal<_Key, __hash_value_type<_Key, _Value>, _Equal>,
+ _Alloc>
+ : __diagnose_hash_table_helper<_Key, _Hash, _Equal, _Alloc>
+ {
+ };
+ #endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Hash, class _Equal, class _Alloc>
class __hash_table
{
public:
typedef _Tpvalue_type;
typedef _Hash hasher;
@@ -947,14 +959,18 @@
typedef typename __rebind_alloc_helper<__node_traits, __next_pointer>::type __pointer_allocator;
typedef __bucket_list_deallocator<__pointer_allocator> __bucket_list_deleter;
typedef unique_ptr<__next_pointer[], __bucket_list_deleter> __bucket_list;
typedef allocator_traits<__pointer_allocator> __pointer_alloc_traits;
typedef typename __bucket_list_deleter::pointer __node_pointer_pointer;
+ #ifndef _LIBCPP_CXX03_LANG
+ static_assert(__diagnose_hash_table_helper<_Tp, _Hash, _Equal, _Alloc>::__trigger_diagnostics(), "");
+ #endif
+
// --- Member data begin ---
__bucket_list __bucket_list_;
__compressed_pair<__first_node, __node_allocator> __p1_;
__compressed_pair<size_type, hasher> __p2_;
__compressed_pair<float, key_equal> __p3_;
// --- Member data end ---
@@ -36,14 +36,18 @@
template <class _Pointer> class __tree_end_node;
template <class _VoidPtr> class __tree_node_base;
template <class _Tp, class _VoidPtr> class __tree_node;
template <class _Key, class _Value>
struct __value_type;
+ template <class _Key, class _CP, class _Compare,
+ bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value>
+ class __map_value_compare;
+
template <class _Allocator> class __map_node_destructor;
template <class _TreeIterator> class _LIBCPP_TEMPLATE_VIS __map_iterator;
template <class _TreeIterator> class _LIBCPP_TEMPLATE_VIS __map_const_iterator;
/*
_NodePtr algorithms
@@ -958,20 +962,32 @@
template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS set;
template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS multiset;
template <class> friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator;
};
- template<class _Tp, class _Compare>
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_DIAGNOSE_WARNING(!std::__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
- "the specified comparator type does not provide a const call operator")
- #endif
- int __diagnose_non_const_comparator();
+ template <class _Tp, class _Compare, class _Allocator>
+ struct __diagnose_tree_helper {
+ static constexpr bool __trigger_diagnostics()
+ _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
+ "the specified comparator type does not provide a const call operator")
+ { return true; }
+ };
+
+ template <class _Key, class _Value, class _KeyComp, class _Alloc>
+ struct __diagnose_tree_helper<
+ __value_type<_Key, _Value>,
+ __map_value_compare<_Key, __value_type<_Key, _Value>, _KeyComp>,
+ _Alloc
+ > : __diagnose_tree_helper<_Key, _KeyComp, _Alloc>
+ {
+ };
+ #endif // !_LIBCPP_CXX03_LANG
template <class _Tp, class _Compare, class _Allocator>
class __tree
{
public:
typedef _Tp value_type;
typedef _Compare value_compare;
@@ -1824,14 +1840,18 @@
#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Compare, class _Allocator>
__tree<_Tp, _Compare, _Allocator>::~__tree()
{
static_assert((is_copy_constructible<value_compare>::value),
"Comparator must be copy-constructible.");
+ #ifndef _LIBCPP_CXX03_LANG
+ static_assert((__diagnose_tree_helper<_Tp, _Compare, _Allocator>::
+ __trigger_diagnostics()), "");
+ #endif
destroy(__root());
}
template <class _Tp, class _Compare, class _Allocator>
void
__tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT
{
@@ -89,27 +89,26 @@
#include <cstdlib>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
namespace std {
- class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast
+ class _LIBCPP_EXCEPTION_ABI bad_any_cast : public bad_cast
{
public:
virtual const char* what() const _NOEXCEPT;
};
} // namespace std
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 14
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
void __throw_bad_any_cast()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_any_cast();
#else
_VSTD::abort();
#endif
@@ -573,45 +572,42 @@
inline _LIBCPP_INLINE_VISIBILITY
any make_any(initializer_list<_Up> __il, _Args&&... __args) {
return any(in_place_type<_Tp>, __il, _VSTD::forward<_Args>(__args)...);
}
template <class _ValueType>
inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
_ValueType any_cast(any const & __v)
{
using _RawValueType = __uncvref_t<_ValueType>;
static_assert(is_constructible<_ValueType, _RawValueType const &>::value,
"ValueType is required to be a const lvalue reference "
"or a CopyConstructible type");
auto __tmp = _VSTD::any_cast<add_const_t<_RawValueType>>(&__v);
if (__tmp == nullptr)
__throw_bad_any_cast();
return static_cast<_ValueType>(*__tmp);
}
template <class _ValueType>
inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
_ValueType any_cast(any & __v)
{
using _RawValueType = __uncvref_t<_ValueType>;
static_assert(is_constructible<_ValueType, _RawValueType &>::value,
"ValueType is required to be an lvalue reference "
"or a CopyConstructible type");
auto __tmp = _VSTD::any_cast<_RawValueType>(&__v);
if (__tmp == nullptr)
__throw_bad_any_cast();
return static_cast<_ValueType>(*__tmp);
}
template <class _ValueType>
inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
_ValueType any_cast(any && __v)
{
using _RawValueType = __uncvref_t<_ValueType>;
static_assert(is_constructible<_ValueType, _RawValueType>::value,
"ValueType is required to be an rvalue reference "
"or a CopyConstructible type");
auto __tmp = _VSTD::any_cast<_RawValueType>(&__v);
@@ -2,14 +2,15 @@
__memory
algorithm
any
chrono
coroutine
deque
dynarray
+ filesystem
forward_list
functional
iterator
list
map
memory_resource
numeric
@@ -4,593 +4,8 @@
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
- #ifndef _LIBCPP_EXPERIMENTAL_ANY
- #define _LIBCPP_EXPERIMENTAL_ANY
-
- /*
- experimental/any synopsis
-
- namespace std {
- namespace experimental {
- inline namespace fundamentals_v1 {
-
- class bad_any_cast : public bad_cast
- {
- public:
- virtual const char* what() const noexcept;
- };
-
- class any
- {
- public:
-
- // 6.3.1 any construct/destruct
- any() noexcept;
-
- any(const any& other);
- any(any&& other) noexcept;
-
- template <class ValueType>
- any(ValueType&& value);
-
- ~any();
-
- // 6.3.2 any assignments
- any& operator=(const any& rhs);
- any& operator=(any&& rhs) noexcept;
-
- template <class ValueType>
- any& operator=(ValueType&& rhs);
-
- // 6.3.3 any modifiers
- void clear() noexcept;
- void swap(any& rhs) noexcept;
-
- // 6.3.4 any observers
- bool empty() const noexcept;
- const type_info& type() const noexcept;
- };
-
- // 6.4 Non-member functions
- void swap(any& x, any& y) noexcept;
-
- template<class ValueType>
- ValueType any_cast(const any& operand);
- template<class ValueType>
- ValueType any_cast(any& operand);
- template<class ValueType>
- ValueType any_cast(any&& operand);
-
- template<class ValueType>
- const ValueType* any_cast(const any* operand) noexcept;
- template<class ValueType>
- ValueType* any_cast(any* operand) noexcept;
-
- } // namespace fundamentals_v1
- } // namespace experimental
- } // namespace std
-
- */
-
- #include <experimental/__config>
- #include <memory>
- #include <new>
- #include <typeinfo>
- #include <type_traits>
- #include <cstdlib>
-
- #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
- #pragma GCC system_header
- #endif
-
- #if defined(_LIBCPP_WARN_ON_DEPRECATED_EXPERIMENTAL_HEADER)
- # warning "<experimental/any> is deprecated and will be removed in the next release. Please use C++17's <any> instead."
- #endif
-
- _LIBCPP_BEGIN_NAMESPACE_LFTS
-
- class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast
- {
- public:
- virtual const char* what() const _NOEXCEPT;
- };
-
- #if _LIBCPP_STD_VER > 11// C++ > 11
-
- _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
- _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
- void __throw_bad_any_cast()
- {
- #ifndef _LIBCPP_NO_EXCEPTIONS
- throw bad_any_cast();
- #else
- _VSTD::abort();
- #endif
- }
-
- // Forward declarations
- class any;
-
- template <class _ValueType>
- typename add_pointer<typename add_const<_ValueType>::type>::type
- _LIBCPP_INLINE_VISIBILITY
- any_cast(any const *) _NOEXCEPT;
-
- template <class _ValueType>
- typename add_pointer<_ValueType>::type
- _LIBCPP_INLINE_VISIBILITY
- any_cast(any *) _NOEXCEPT;
-
- namespace __any_imp
- {
- typedef typename aligned_storage<3*sizeof(void*), alignment_of<void*>::value>::type
- _Buffer;
-
- template <class _Tp>
- struct _IsSmallObject
- : public integral_constant<bool
- , sizeof(_Tp) <= sizeof(_Buffer)
- && alignment_of<_Buffer>::value
- % alignment_of<_Tp>::value == 0
- && is_nothrow_move_constructible<_Tp>::value
- >
- {};
-
- enum class _Action
- {
- _Destroy,
- _Copy,
- _Move,
- _Get,
- _TypeInfo
- };
-
- template <class _Tp>
- struct _SmallHandler;
-
- template <class _Tp>
- struct _LargeHandler;
-
- template <class _Tp>
- using _Handler = typename conditional<_IsSmallObject<_Tp>::value
- , _SmallHandler<_Tp>
- , _LargeHandler<_Tp>
- >::type;
- template <class _ValueType>
- using _EnableIfNotAny = typename
- enable_if<
- !is_same<typename decay<_ValueType>::type, any>::value
- >::type;
-
- } // namespace __any_imp
-
- class any
- {
- public:
- // 6.3.1 any construct/destruct
- _LIBCPP_INLINE_VISIBILITY
- any() _NOEXCEPT : __h(nullptr) {}
-
- _LIBCPP_INLINE_VISIBILITY
- any(any const & __other) : __h(nullptr)
- {
- if (__other.__h) __other.__call(_Action::_Copy, this);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- any(any && __other) _NOEXCEPT : __h(nullptr)
- {
- if (__other.__h) __other.__call(_Action::_Move, this);
- }
-
- template <
- class _ValueType
- , class = __any_imp::_EnableIfNotAny<_ValueType>
- >
- _LIBCPP_INLINE_VISIBILITY
- any(_ValueType && __value);
-
- _LIBCPP_INLINE_VISIBILITY
- ~any()
- {
- this->clear();
- }
-
- // 6.3.2 any assignments
- _LIBCPP_INLINE_VISIBILITY
- any & operator=(any const & __rhs)
- {
- any(__rhs).swap(*this);
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- any & operator=(any && __rhs) _NOEXCEPT
- {
- any(_VSTD::move(__rhs)).swap(*this);
- return *this;
- }
-
- template <
- class _ValueType
- , class = __any_imp::_EnableIfNotAny<_ValueType>
- >
- _LIBCPP_INLINE_VISIBILITY
- any & operator=(_ValueType && __rhs);
-
- // 6.3.3 any modifiers
- _LIBCPP_INLINE_VISIBILITY
- void clear() _NOEXCEPT
- {
- if (__h) this->__call(_Action::_Destroy);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- void swap(any & __rhs) _NOEXCEPT;
-
- // 6.3.4 any observers
- _LIBCPP_INLINE_VISIBILITY
- bool empty() const _NOEXCEPT
- {
- return __h == nullptr;
- }
-
- #if !defined(_LIBCPP_NO_RTTI)
- _LIBCPP_INLINE_VISIBILITY
- const type_info & type() const _NOEXCEPT
- {
- if (__h) {
- return *static_cast<type_info const *>(this->__call(_Action::_TypeInfo));
- } else {
- return typeid(void);
- }
- }
- #endif
-
- private:
- typedef __any_imp::_Action _Action;
-
- typedef void* (*_HandleFuncPtr)(_Action, any const *, any *, const type_info *);
-
- union _Storage
- {
- void * __ptr;
- __any_imp::_Buffer __buf;
- };
-
- _LIBCPP_ALWAYS_INLINE
- void * __call(_Action __a, any * __other = nullptr,
- type_info const * __info = nullptr) const
- {
- return __h(__a, this, __other, __info);
- }
-
- _LIBCPP_ALWAYS_INLINE
- void * __call(_Action __a, any * __other = nullptr,
- type_info const * __info = nullptr)
- {
- return __h(__a, this, __other, __info);
- }
-
- template <class>
- friend struct __any_imp::_SmallHandler;
- template <class>
- friend struct __any_imp::_LargeHandler;
-
- template <class _ValueType>
- friend typename add_pointer<typename add_const<_ValueType>::type>::type
- any_cast(any const *) _NOEXCEPT;
-
- template <class _ValueType>
- friend typename add_pointer<_ValueType>::type
- any_cast(any *) _NOEXCEPT;
-
- _HandleFuncPtr __h;
- _Storage __s;
- };
-
- namespace __any_imp
- {
-
- template <class _Tp>
- struct _LIBCPP_TEMPLATE_VIS _SmallHandler
- {
- _LIBCPP_INLINE_VISIBILITY
- static void* __handle(_Action __act, any const * __this, any * __other,
- type_info const * __info)
- {
- switch (__act)
- {
- case _Action::_Destroy:
- __destroy(const_cast<any &>(*__this));
- return nullptr;
- case _Action::_Copy:
- __copy(*__this, *__other);
- return nullptr;
- case _Action::_Move:
- __move(const_cast<any &>(*__this), *__other);
- return nullptr;
- case _Action::_Get:
- return __get(const_cast<any &>(*__this), __info);
- case _Action::_TypeInfo:
- return __type_info();
- }
- }
-
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- static void __create(any & __dest, _Up && __v)
- {
- ::new (static_cast<void*>(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Up>(__v));
- __dest.__h = &_SmallHandler::__handle;
- }
-
- private:
- _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
- static void __destroy(any & __this)
- {
- _Tp & __value = *static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf));
- __value.~_Tp();
- __this.__h = nullptr;
- }
-
- _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
- static void __copy(any const & __this, any & __dest)
- {
- _SmallHandler::__create(__dest, *static_cast<_Tp const *>(
- static_cast<void const *>(&__this.__s.__buf)));
- }
-
- _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
- static void __move(any & __this, any & __dest)
- {
- _SmallHandler::__create(__dest, _VSTD::move(
- *static_cast<_Tp*>(static_cast<void*>(&__this.__s.__buf))));
- __destroy(__this);
- }
-
- _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
- static void* __get(any & __this, type_info const * __info)
- {
- #if !defined(_LIBCPP_NO_RTTI)
- if (typeid(_Tp) == *__info) {
- return static_cast<void*>(&__this.__s.__buf);
- }
- return nullptr;
- #else
- return static_cast<void*>(&__this.__s.__buf);
- #endif
- }
-
- _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
- static void* __type_info()
- {
- #if !defined(_LIBCPP_NO_RTTI)
- return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
- #else
- return nullptr;
- #endif
- }
- };
-
- template <class _Tp>
- struct _LIBCPP_TEMPLATE_VIS _LargeHandler
- {
- _LIBCPP_INLINE_VISIBILITY
- static void* __handle(_Action __act, any const * __this, any * __other,
- type_info const * __info)
- {
- switch (__act)
- {
- case _Action::_Destroy:
- __destroy(const_cast<any &>(*__this));
- return nullptr;
- case _Action::_Copy:
- __copy(*__this, *__other);
- return nullptr;
- case _Action::_Move:
- __move(const_cast<any &>(*__this), *__other);
- return nullptr;
- case _Action::_Get:
- return __get(const_cast<any &>(*__this), __info);
- case _Action::_TypeInfo:
- return __type_info();
- }
- }
-
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- static void __create(any & __dest, _Up && __v)
- {
- typedef allocator<_Tp> _Alloc;
- typedef __allocator_destructor<_Alloc> _Dp;
- _Alloc __a;
- unique_ptr<_Tp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Up>(__v));
- __dest.__s.__ptr = __hold.release();
- __dest.__h = &_LargeHandler::__handle;
- }
-
- private:
-
- _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
- static void __destroy(any & __this)
- {
- delete static_cast<_Tp*>(__this.__s.__ptr);
- __this.__h = nullptr;
- }
-
- _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
- static void __copy(any const & __this, any & __dest)
- {
- _LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s.__ptr));
- }
-
- _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
- static void __move(any & __this, any & __dest)
- {
- __dest.__s.__ptr = __this.__s.__ptr;
- __dest.__h = &_LargeHandler::__handle;
- __this.__h = nullptr;
- }
-
- _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
- static void* __get(any & __this, type_info const * __info)
- {
- #if !defined(_LIBCPP_NO_RTTI)
- if (typeid(_Tp) == *__info) {
- return static_cast<void*>(__this.__s.__ptr);
- }
- return nullptr;
- #else
- return static_cast<void*>(__this.__s.__ptr);
- #endif
- }
-
- _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
- static void* __type_info()
- {
- #if !defined(_LIBCPP_NO_RTTI)
- return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
- #else
- return nullptr;
- #endif
- }
- };
-
- } // namespace __any_imp
-
-
- template <class _ValueType, class>
- any::any(_ValueType && __v) : __h(nullptr)
- {
- typedef typename decay<_ValueType>::type _Tp;
- static_assert(is_copy_constructible<_Tp>::value,
- "_ValueType must be CopyConstructible.");
- typedef __any_imp::_Handler<_Tp> _HandlerType;
- _HandlerType::__create(*this, _VSTD::forward<_ValueType>(__v));
- }
-
- template <class _ValueType, class>
- any & any::operator=(_ValueType && __v)
- {
- typedef typename decay<_ValueType>::type _Tp;
- static_assert(is_copy_constructible<_Tp>::value,
- "_ValueType must be CopyConstructible.");
- any(_VSTD::forward<_ValueType>(__v)).swap(*this);
- return *this;
- }
-
- inline
- void any::swap(any & __rhs) _NOEXCEPT
- {
- if (__h && __rhs.__h) {
- any __tmp;
- __rhs.__call(_Action::_Move, &__tmp);
- this->__call(_Action::_Move, &__rhs);
- __tmp.__call(_Action::_Move, this);
- }
- else if (__h) {
- this->__call(_Action::_Move, &__rhs);
- }
- else if (__rhs.__h) {
- __rhs.__call(_Action::_Move, this);
- }
- }
-
- // 6.4 Non-member functions
-
- inline _LIBCPP_INLINE_VISIBILITY
- void swap(any & __lhs, any & __rhs) _NOEXCEPT
- {
- __lhs.swap(__rhs);
- }
-
- template <class _ValueType>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
- _ValueType any_cast(any const & __v)
- {
- static_assert(
- is_reference<_ValueType>::value
- || is_copy_constructible<_ValueType>::value,
- "_ValueType is required to be a reference or a CopyConstructible type.");
- typedef typename add_const<typename remove_reference<_ValueType>::type>::type
- _Tp;
- _Tp * __tmp = any_cast<_Tp>(&__v);
- if (__tmp == nullptr)
- __throw_bad_any_cast();
- return *__tmp;
- }
-
- template <class _ValueType>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
- _ValueType any_cast(any & __v)
- {
- static_assert(
- is_reference<_ValueType>::value
- || is_copy_constructible<_ValueType>::value,
- "_ValueType is required to be a reference or a CopyConstructible type.");
- typedef typename remove_reference<_ValueType>::type _Tp;
- _Tp * __tmp = any_cast<_Tp>(&__v);
- if (__tmp == nullptr)
- __throw_bad_any_cast();
- return *__tmp;
- }
-
- template <class _ValueType>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
- _ValueType any_cast(any && __v)
- {
- static_assert(
- is_reference<_ValueType>::value
- || is_copy_constructible<_ValueType>::value,
- "_ValueType is required to be a reference or a CopyConstructible type.");
- typedef typename remove_reference<_ValueType>::type _Tp;
- _Tp * __tmp = any_cast<_Tp>(&__v);
- if (__tmp == nullptr)
- __throw_bad_any_cast();
- return *__tmp;
- }
-
- template <class _ValueType>
- inline
- typename add_pointer<typename add_const<_ValueType>::type>::type
- any_cast(any const * __any) _NOEXCEPT
- {
- static_assert(!is_reference<_ValueType>::value,
- "_ValueType may not be a reference.");
- return any_cast<_ValueType>(const_cast<any *>(__any));
- }
-
- template <class _ValueType>
- typename add_pointer<_ValueType>::type
- any_cast(any * __any) _NOEXCEPT
- {
- using __any_imp::_Action;
- static_assert(!is_reference<_ValueType>::value,
- "_ValueType may not be a reference.");
- typedef typename add_pointer<_ValueType>::type _ReturnType;
- if (__any && __any->__h) {
-
- return static_cast<_ReturnType>(
- __any->__call(_Action::_Get, nullptr,
- #if !defined(_LIBCPP_NO_RTTI)
- &typeid(_ValueType)
- #else
- nullptr
- #endif
- ));
-
- }
- return nullptr;
- }
-
- #endif // _LIBCPP_STD_VER > 11
-
- _LIBCPP_END_NAMESPACE_LFTS
-
- #endif // _LIBCPP_EXPERIMENTAL_ANY
+ #error "<experimental/any> has been removed. Use <any> instead."
@@ -4,924 +4,8 @@
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
- #ifndef _LIBCPP_EXPERIMENTAL_OPTIONAL
- #define _LIBCPP_EXPERIMENTAL_OPTIONAL
-
- /*
- optional synopsis
-
- // C++1y
-
- namespace std { namespace experimental { inline namespace fundamentals_v1 {
-
- // 5.3, optional for object types
- template <class T> class optional;
-
- // 5.4, In-place construction
- struct in_place_t{};
- constexpr in_place_t in_place{};
-
- // 5.5, No-value state indicator
- struct nullopt_t{see below};
- constexpr nullopt_t nullopt(unspecified);
-
- // 5.6, Class bad_optional_access
- class bad_optional_access;
-
- // 5.7, Relational operators
- template <class T>
- constexpr bool operator==(const optional<T>&, const optional<T>&);
- template <class T>
- constexpr bool operator!=(const optional<T>&, const optional<T>&);
- template <class T>
- constexpr bool operator<(const optional<T>&, const optional<T>&);
- template <class T>
- constexpr bool operator>(const optional<T>&, const optional<T>&);
- template <class T>
- constexpr bool operator<=(const optional<T>&, const optional<T>&);
- template <class T>
- constexpr bool operator>=(const optional<T>&, const optional<T>&);
-
- // 5.8, Comparison with nullopt
- template <class T> constexpr bool operator==(const optional<T>&, nullopt_t) noexcept;
- template <class T> constexpr bool operator==(nullopt_t, const optional<T>&) noexcept;
- template <class T> constexpr bool operator!=(const optional<T>&, nullopt_t) noexcept;
- template <class T> constexpr bool operator!=(nullopt_t, const optional<T>&) noexcept;
- template <class T> constexpr bool operator<(const optional<T>&, nullopt_t) noexcept;
- template <class T> constexpr bool operator<(nullopt_t, const optional<T>&) noexcept;
- template <class T> constexpr bool operator<=(const optional<T>&, nullopt_t) noexcept;
- template <class T> constexpr bool operator<=(nullopt_t, const optional<T>&) noexcept;
- template <class T> constexpr bool operator>(const optional<T>&, nullopt_t) noexcept;
- template <class T> constexpr bool operator>(nullopt_t, const optional<T>&) noexcept;
- template <class T> constexpr bool operator>=(const optional<T>&, nullopt_t) noexcept;
- template <class T> constexpr bool operator>=(nullopt_t, const optional<T>&) noexcept;
-
- // 5.9, Comparison with T
- template <class T> constexpr bool operator==(const optional<T>&, const T&);
- template <class T> constexpr bool operator==(const T&, const optional<T>&);
- template <class T> constexpr bool operator!=(const optional<T>&, const T&);
- template <class T> constexpr bool operator!=(const T&, const optional<T>&);
- template <class T> constexpr bool operator<(const optional<T>&, const T&);
- template <class T> constexpr bool operator<(const T&, const optional<T>&);
- template <class T> constexpr bool operator<=(const optional<T>&, const T&);
- template <class T> constexpr bool operator<=(const T&, const optional<T>&);
- template <class T> constexpr bool operator>(const optional<T>&, const T&);
- template <class T> constexpr bool operator>(const T&, const optional<T>&);
- template <class T> constexpr bool operator>=(const optional<T>&, const T&);
- template <class T> constexpr bool operator>=(const T&, const optional<T>&);
-
- // 5.10, Specialized algorithms
- template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below);
- template <class T> constexpr optional<see below> make_optional(T&&);
-
- template <class T>
- class optional
- {
- public:
- typedef T value_type;
-
- // 5.3.1, Constructors
- constexpr optional() noexcept;
- constexpr optional(nullopt_t) noexcept;
- optional(const optional&);
- optional(optional&&) noexcept(see below);
- constexpr optional(const T&);
- constexpr optional(T&&);
- template <class... Args> constexpr explicit optional(in_place_t, Args&&...);
- template <class U, class... Args>
- constexpr explicit optional(in_place_t, initializer_list<U>, Args&&...);
-
- // 5.3.2, Destructor
- ~optional();
-
- // 5.3.3, Assignment
- optional& operator=(nullopt_t) noexcept;
- optional& operator=(const optional&);
- optional& operator=(optional&&) noexcept(see below);
- template <class U> optional& operator=(U&&);
- template <class... Args> void emplace(Args&&...);
- template <class U, class... Args>
- void emplace(initializer_list<U>, Args&&...);
-
- // 5.3.4, Swap
- void swap(optional&) noexcept(see below);
-
- // 5.3.5, Observers
- constexpr T const* operator ->() const;
- constexpr T* operator ->();
- constexpr T const& operator *() const &;
- constexpr T& operator *() &;
- constexpr T&& operator *() &&;
- constexpr const T&& operator *() const &&;
- constexpr explicit operator bool() const noexcept;
- constexpr T const& value() const &;
- constexpr T& value() &;
- constexpr T&& value() &&;
- constexpr const T&& value() const &&;
- template <class U> constexpr T value_or(U&&) const &;
- template <class U> constexpr T value_or(U&&) &&;
-
- private:
- T* val; // exposition only
- };
-
- } // namespace fundamentals_v1
- } // namespace experimental
-
- // 5.11, Hash support
- template <class T> struct hash;
- template <class T> struct hash<experimental::optional<T>>;
-
- } // namespace std
-
- */
-
- #include <experimental/__config>
- #include <functional>
- #include <stdexcept>
- #if _LIBCPP_STD_VER > 11
- #include <initializer_list>
- #include <type_traits>
- #include <new>
- #include <__functional_base>
- #include <__debug>
- #endif
-
- #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
- #pragma GCC system_header
- #endif
-
- _LIBCPP_PUSH_MACROS
- #include <__undef_macros>
-
-
- #if defined(_LIBCPP_WARN_ON_DEPRECATED_EXPERIMENTAL_HEADER)
- # warning "<experimental/optional> is deprecated and will be removed in the next release. Please use C++17's <optional> instead."
- #endif
-
-
- _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
- class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access
- : public std::logic_error
- {
- public:
- bad_optional_access() : std::logic_error("Bad optional Access") {}
-
- // Get the key function ~bad_optional_access() into the dylib
- virtual ~bad_optional_access() _NOEXCEPT;
- };
-
- _LIBCPP_END_NAMESPACE_EXPERIMENTAL
-
-
- #if _LIBCPP_STD_VER > 11
-
- _LIBCPP_BEGIN_NAMESPACE_LFTS
-
- struct in_place_t {};
- constexpr in_place_t in_place{};
-
- struct nullopt_t
- {
- explicit constexpr nullopt_t(int) noexcept {}
- };
-
- constexpr nullopt_t nullopt{0};
-
- template <class _Tp, bool = is_trivially_destructible<_Tp>::value>
- class __optional_storage
- {
- protected:
- typedef _Tp value_type;
- union
- {
- char __null_state_;
- value_type __val_;
- };
- bool __engaged_ = false;
-
- _LIBCPP_INLINE_VISIBILITY
- ~__optional_storage()
- {
- if (__engaged_)
- __val_.~value_type();
- }
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr __optional_storage() noexcept
- : __null_state_('\0') {}
-
- _LIBCPP_INLINE_VISIBILITY
- __optional_storage(const __optional_storage& __x)
- : __engaged_(__x.__engaged_)
- {
- if (__engaged_)
- ::new((void*)_VSTD::addressof(__val_)) value_type(__x.__val_);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- __optional_storage(__optional_storage&& __x)
- noexcept(is_nothrow_move_constructible<value_type>::value)
- : __engaged_(__x.__engaged_)
- {
- if (__engaged_)
- ::new((void*)_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_));
- }
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr __optional_storage(const value_type& __v)
- : __val_(__v),
- __engaged_(true) {}
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr __optional_storage(value_type&& __v)
- : __val_(_VSTD::move(__v)),
- __engaged_(true) {}
-
- template <class... _Args>
- _LIBCPP_INLINE_VISIBILITY
- constexpr
- explicit __optional_storage(in_place_t, _Args&&... __args)
- : __val_(_VSTD::forward<_Args>(__args)...),
- __engaged_(true) {}
- };
-
- template <class _Tp>
- class __optional_storage<_Tp, true>
- {
- protected:
- typedef _Tp value_type;
- union
- {
- char __null_state_;
- value_type __val_;
- };
- bool __engaged_ = false;
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr __optional_storage() noexcept
- : __null_state_('\0') {}
-
- _LIBCPP_INLINE_VISIBILITY
- __optional_storage(const __optional_storage& __x)
- : __engaged_(__x.__engaged_)
- {
- if (__engaged_)
- ::new((void*)_VSTD::addressof(__val_)) value_type(__x.__val_);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- __optional_storage(__optional_storage&& __x)
- noexcept(is_nothrow_move_constructible<value_type>::value)
- : __engaged_(__x.__engaged_)
- {
- if (__engaged_)
- ::new((void*)_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_));
- }
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr __optional_storage(const value_type& __v)
- : __val_(__v),
- __engaged_(true) {}
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr __optional_storage(value_type&& __v)
- : __val_(_VSTD::move(__v)),
- __engaged_(true) {}
-
- template <class... _Args>
- _LIBCPP_INLINE_VISIBILITY
- constexpr
- explicit __optional_storage(in_place_t, _Args&&... __args)
- : __val_(_VSTD::forward<_Args>(__args)...),
- __engaged_(true) {}
- };
-
- template <class _Tp>
- class optional
- : private __optional_storage<_Tp>
- {
- typedef __optional_storage<_Tp> __base;
- public:
- typedef _Tp value_type;
-
- static_assert(!is_reference<value_type>::value,
- "Instantiation of optional with a reference type is ill-formed.");
- static_assert(!is_same<typename remove_cv<value_type>::type, in_place_t>::value,
- "Instantiation of optional with a in_place_t type is ill-formed.");
- static_assert(!is_same<typename remove_cv<value_type>::type, nullopt_t>::value,
- "Instantiation of optional with a nullopt_t type is ill-formed.");
- static_assert(is_object<value_type>::value,
- "Instantiation of optional with a non-object type is undefined behavior.");
- static_assert(is_nothrow_destructible<value_type>::value,
- "Instantiation of optional with an object type that is not noexcept destructible is undefined behavior.");
-
- _LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {}
- _LIBCPP_INLINE_VISIBILITY optional(const optional&) = default;
- _LIBCPP_INLINE_VISIBILITY optional(optional&&) = default;
- _LIBCPP_INLINE_VISIBILITY ~optional() = default;
- _LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {}
- _LIBCPP_INLINE_VISIBILITY constexpr optional(const value_type& __v)
- : __base(__v) {}
- _LIBCPP_INLINE_VISIBILITY constexpr optional(value_type&& __v)
- : __base(_VSTD::move(__v)) {}
-
- template <class... _Args,
- class = typename enable_if
- <
- is_constructible<value_type, _Args...>::value
- >::type
- >
- _LIBCPP_INLINE_VISIBILITY
- constexpr
- explicit optional(in_place_t, _Args&&... __args)
- : __base(in_place, _VSTD::forward<_Args>(__args)...) {}
-
- template <class _Up, class... _Args,
- class = typename enable_if
- <
- is_constructible<value_type, initializer_list<_Up>&, _Args...>::value
- >::type
- >
- _LIBCPP_INLINE_VISIBILITY
- constexpr
- explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
- : __base(in_place, __il, _VSTD::forward<_Args>(__args)...) {}
-
- _LIBCPP_INLINE_VISIBILITY
- optional& operator=(nullopt_t) noexcept
- {
- if (this->__engaged_)
- {
- this->__val_.~value_type();
- this->__engaged_ = false;
- }
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- optional&
- operator=(const optional& __opt)
- {
- if (this->__engaged_ == __opt.__engaged_)
- {
- if (this->__engaged_)
- this->__val_ = __opt.__val_;
- }
- else
- {
- if (this->__engaged_)
- this->__val_.~value_type();
- else
- ::new((void*)_VSTD::addressof(this->__val_)) value_type(__opt.__val_);
- this->__engaged_ = __opt.__engaged_;
- }
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- optional&
- operator=(optional&& __opt)
- noexcept(is_nothrow_move_assignable<value_type>::value &&
- is_nothrow_move_constructible<value_type>::value)
- {
- if (this->__engaged_ == __opt.__engaged_)
- {
- if (this->__engaged_)
- this->__val_ = _VSTD::move(__opt.__val_);
- }
- else
- {
- if (this->__engaged_)
- this->__val_.~value_type();
- else
- ::new((void*)_VSTD::addressof(this->__val_))
- value_type(_VSTD::move(__opt.__val_));
- this->__engaged_ = __opt.__engaged_;
- }
- return *this;
- }
-
- template <class _Up,
- class = typename enable_if
- <
- is_same<typename remove_reference<_Up>::type, value_type>::value &&
- is_constructible<value_type, _Up>::value &&
- is_assignable<value_type&, _Up>::value
- >::type
- >
- _LIBCPP_INLINE_VISIBILITY
- optional&
- operator=(_Up&& __v)
- {
- if (this->__engaged_)
- this->__val_ = _VSTD::forward<_Up>(__v);
- else
- {
- ::new((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Up>(__v));
- this->__engaged_ = true;
- }
- return *this;
- }
-
- template <class... _Args,
- class = typename enable_if
- <
- is_constructible<value_type, _Args...>::value
- >::type
- >
- _LIBCPP_INLINE_VISIBILITY
- void
- emplace(_Args&&... __args)
- {
- *this = nullopt;
- ::new((void*)_VSTD::addressof(this->__val_))
- value_type(_VSTD::forward<_Args>(__args)...);
- this->__engaged_ = true;
- }
-
- template <class _Up, class... _Args,
- class = typename enable_if
- <
- is_constructible<value_type, initializer_list<_Up>&, _Args...>::value
- >::type
- >
- _LIBCPP_INLINE_VISIBILITY
- void
- emplace(initializer_list<_Up> __il, _Args&&... __args)
- {
- *this = nullopt;
- ::new((void*)_VSTD::addressof(this->__val_))
- value_type(__il, _VSTD::forward<_Args>(__args)...);
- this->__engaged_ = true;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- void
- swap(optional& __opt)
- noexcept(is_nothrow_move_constructible<value_type>::value &&
- __is_nothrow_swappable<value_type>::value)
- {
- using _VSTD::swap;
- if (this->__engaged_ == __opt.__engaged_)
- {
- if (this->__engaged_)
- swap(this->__val_, __opt.__val_);
- }
- else
- {
- if (this->__engaged_)
- {
- ::new((void*)_VSTD::addressof(__opt.__val_))
- value_type(_VSTD::move(this->__val_));
- this->__val_.~value_type();
- }
- else
- {
- ::new((void*)_VSTD::addressof(this->__val_))
- value_type(_VSTD::move(__opt.__val_));
- __opt.__val_.~value_type();
- }
- swap(this->__engaged_, __opt.__engaged_);
- }
- }
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr
- value_type const*
- operator->() const
- {
- _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value");
- #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
- return __builtin_addressof(this->__val_);
- #else
- return __operator_arrow(__has_operator_addressof<value_type>{});
- #endif
- }
-
- _LIBCPP_INLINE_VISIBILITY
- value_type*
- operator->()
- {
- _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value");
- return _VSTD::addressof(this->__val_);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr
- const value_type&
- operator*() const
- {
- _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value");
- return this->__val_;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- value_type&
- operator*()
- {
- _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value");
- return this->__val_;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr explicit operator bool() const noexcept {return this->__engaged_;}
-
- _LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY
- #ifndef _LIBCPP_NO_EXCEPTIONS
- _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
- #endif
- constexpr void __throw_bad_optional_access() const
- {
- #ifndef _LIBCPP_NO_EXCEPTIONS
- throw bad_optional_access();
- #else
- _VSTD::abort();
- #endif
- }
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
- constexpr value_type const& value() const
- {
- if (!this->__engaged_)
- __throw_bad_optional_access();
- return this->__val_;
- }
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
- value_type& value()
- {
- if (!this->__engaged_)
- __throw_bad_optional_access();
- return this->__val_;
- }
-
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- constexpr value_type value_or(_Up&& __v) const&
- {
- static_assert(is_copy_constructible<value_type>::value,
- "optional<T>::value_or: T must be copy constructible");
- static_assert(is_convertible<_Up, value_type>::value,
- "optional<T>::value_or: U must be convertible to T");
- return this->__engaged_ ? this->__val_ :
- static_cast<value_type>(_VSTD::forward<_Up>(__v));
- }
-
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- value_type value_or(_Up&& __v) &&
- {
- static_assert(is_move_constructible<value_type>::value,
- "optional<T>::value_or: T must be move constructible");
- static_assert(is_convertible<_Up, value_type>::value,
- "optional<T>::value_or: U must be convertible to T");
- return this->__engaged_ ? _VSTD::move(this->__val_) :
- static_cast<value_type>(_VSTD::forward<_Up>(__v));
- }
-
- private:
- _LIBCPP_INLINE_VISIBILITY
- value_type const*
- __operator_arrow(true_type) const
- {
- return _VSTD::addressof(this->__val_);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr
- value_type const*
- __operator_arrow(false_type) const
- {
- return &this->__val_;
- }
- };
-
- // Comparisons between optionals
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator==(const optional<_Tp>& __x, const optional<_Tp>& __y)
- {
- if (static_cast<bool>(__x) != static_cast<bool>(__y))
- return false;
- if (!static_cast<bool>(__x))
- return true;
- return *__x == *__y;
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator!=(const optional<_Tp>& __x, const optional<_Tp>& __y)
- {
- return !(__x == __y);
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator<(const optional<_Tp>& __x, const optional<_Tp>& __y)
- {
- if (!static_cast<bool>(__y))
- return false;
- if (!static_cast<bool>(__x))
- return true;
- return *__x < *__y;
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator>(const optional<_Tp>& __x, const optional<_Tp>& __y)
- {
- return __y < __x;
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator<=(const optional<_Tp>& __x, const optional<_Tp>& __y)
- {
- return !(__y < __x);
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator>=(const optional<_Tp>& __x, const optional<_Tp>& __y)
- {
- return !(__x < __y);
- }
-
-
- // Comparisons with nullopt
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator==(const optional<_Tp>& __x, nullopt_t) noexcept
- {
- return !static_cast<bool>(__x);
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator==(nullopt_t, const optional<_Tp>& __x) noexcept
- {
- return !static_cast<bool>(__x);
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator!=(const optional<_Tp>& __x, nullopt_t) noexcept
- {
- return static_cast<bool>(__x);
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator!=(nullopt_t, const optional<_Tp>& __x) noexcept
- {
- return static_cast<bool>(__x);
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator<(const optional<_Tp>&, nullopt_t) noexcept
- {
- return false;
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator<(nullopt_t, const optional<_Tp>& __x) noexcept
- {
- return static_cast<bool>(__x);
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator<=(const optional<_Tp>& __x, nullopt_t) noexcept
- {
- return !static_cast<bool>(__x);
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator<=(nullopt_t, const optional<_Tp>&) noexcept
- {
- return true;
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator>(const optional<_Tp>& __x, nullopt_t) noexcept
- {
- return static_cast<bool>(__x);
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator>(nullopt_t, const optional<_Tp>&) noexcept
- {
- return false;
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator>=(const optional<_Tp>&, nullopt_t) noexcept
- {
- return true;
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator>=(nullopt_t, const optional<_Tp>& __x) noexcept
- {
- return !static_cast<bool>(__x);
- }
-
- // Comparisons with T
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator==(const optional<_Tp>& __x, const _Tp& __v)
- {
- return static_cast<bool>(__x) ? *__x == __v : false;
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator==(const _Tp& __v, const optional<_Tp>& __x)
- {
- return static_cast<bool>(__x) ? *__x == __v : false;
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator!=(const optional<_Tp>& __x, const _Tp& __v)
- {
- return static_cast<bool>(__x) ? !(*__x == __v) : true;
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator!=(const _Tp& __v, const optional<_Tp>& __x)
- {
- return static_cast<bool>(__x) ? !(*__x == __v) : true;
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator<(const optional<_Tp>& __x, const _Tp& __v)
- {
- return static_cast<bool>(__x) ? less<_Tp>{}(*__x, __v) : true;
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator<(const _Tp& __v, const optional<_Tp>& __x)
- {
- return static_cast<bool>(__x) ? less<_Tp>{}(__v, *__x) : false;
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator<=(const optional<_Tp>& __x, const _Tp& __v)
- {
- return !(__x > __v);
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator<=(const _Tp& __v, const optional<_Tp>& __x)
- {
- return !(__v > __x);
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator>(const optional<_Tp>& __x, const _Tp& __v)
- {
- return static_cast<bool>(__x) ? __v < __x : false;
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator>(const _Tp& __v, const optional<_Tp>& __x)
- {
- return static_cast<bool>(__x) ? __x < __v : true;
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator>=(const optional<_Tp>& __x, const _Tp& __v)
- {
- return !(__x < __v);
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- bool
- operator>=(const _Tp& __v, const optional<_Tp>& __x)
- {
- return !(__v < __x);
- }
-
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- void
- swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y)))
- {
- __x.swap(__y);
- }
-
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr
- optional<typename decay<_Tp>::type>
- make_optional(_Tp&& __v)
- {
- return optional<typename decay<_Tp>::type>(_VSTD::forward<_Tp>(__v));
- }
-
- _LIBCPP_END_NAMESPACE_LFTS
-
- _LIBCPP_BEGIN_NAMESPACE_STD
-
- template <class _Tp>
- struct _LIBCPP_TEMPLATE_VIS hash<std::experimental::optional<_Tp> >
- {
- typedef std::experimental::optional<_Tp> argument_type;
- typedef size_tresult_type;
-
- _LIBCPP_INLINE_VISIBILITY
- result_type operator()(const argument_type& __opt) const _NOEXCEPT
- {
- return static_cast<bool>(__opt) ? hash<_Tp>()(*__opt) : 0;
- }
- };
-
- _LIBCPP_END_NAMESPACE_STD
-
- #endif // _LIBCPP_STD_VER > 11
-
- _LIBCPP_POP_MACROS
-
- #endif // _LIBCPP_EXPERIMENTAL_OPTIONAL
+ #error "<experimental/optional> has been removed. Use <optional> instead."
@@ -34,14 +34,15 @@
basic_filebuf& operator=(basic_filebuf&& rhs);
void swap(basic_filebuf& rhs);
// 27.9.1.4 Members:
bool is_open() const;
basic_filebuf* open(const char* s, ios_base::openmode mode);
basic_filebuf* open(const string& s, ios_base::openmode mode);
+ basic_filebuf* open(const filesystem::path& p, ios_base::openmode mode); // C++17
basic_filebuf* close();
protected:
// 27.9.1.5 Overridden virtual functions:
virtual streamsize showmanyc();
virtual int_type underflow();
virtual int_type uflow();
@@ -73,23 +74,26 @@
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
basic_ifstream();
explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in);
explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in);
+ explicit basic_ifstream(const filesystem::path& p,
+ ios_base::openmode mode = ios_base::in); // C++17
basic_ifstream(basic_ifstream&& rhs);
basic_ifstream& operator=(basic_ifstream&& rhs);
void swap(basic_ifstream& rhs);
basic_filebuf<char_type, traits_type>* rdbuf() const;
bool is_open() const;
void open(const char* s, ios_base::openmode mode = ios_base::in);
void open(const string& s, ios_base::openmode mode = ios_base::in);
+ void open(const filesystem::path& s, ios_base::openmode mode = ios_base::in); // C++17
void close();
};
template <class charT, class traits>
void
swap(basic_ifstream<charT, traits>& x, basic_ifstream<charT, traits>& y);
@@ -107,23 +111,27 @@
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
basic_ofstream();
explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out);
explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out);
+ explicit basic_ofstream(const filesystem::path& p,
+ ios_base::openmode mode = ios_base::out); // C++17
basic_ofstream(basic_ofstream&& rhs);
basic_ofstream& operator=(basic_ofstream&& rhs);
void swap(basic_ofstream& rhs);
basic_filebuf<char_type, traits_type>* rdbuf() const;
bool is_open() const;
void open(const char* s, ios_base::openmode mode = ios_base::out);
void open(const string& s, ios_base::openmode mode = ios_base::out);
+ void open(const filesystem::path& p,
+ ios_base::openmode mode = ios_base::out); // C++17
void close();
};
template <class charT, class traits>
void
swap(basic_ofstream<charT, traits>& x, basic_ofstream<charT, traits>& y);
@@ -141,23 +149,27 @@
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
basic_fstream();
explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
+ explicit basic_fstream(const filesystem::path& p,
+ ios_base::openmode mode = ios_base::in|ios_base::out); C++17
basic_fstream(basic_fstream&& rhs);
basic_fstream& operator=(basic_fstream&& rhs);
void swap(basic_fstream& rhs);
basic_filebuf<char_type, traits_type>* rdbuf() const;
bool is_open() const;
void open(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
void open(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
+ void open(const filesystem::path& s,
+ ios_base::openmode mode = ios_base::in|ios_base::out); // C++17
void close();
};
template <class charT, class traits>
void swap(basic_fstream<charT, traits>& x, basic_fstream<charT, traits>& y);
@@ -170,14 +182,15 @@
#include <__config>
#include <ostream>
#include <istream>
#include <__locale>
#include <cstdio>
#include <cstdlib>
+ #include <filesystem>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
@@ -218,14 +231,20 @@
basic_filebuf* open(const char* __s, ios_base::openmode __mode);
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
basic_filebuf* open(const wchar_t* __s, ios_base::openmode __mode);
#endif
_LIBCPP_INLINE_VISIBILITY
basic_filebuf* open(const string& __s, ios_base::openmode __mode);
+ #if _LIBCPP_STD_VER >= 17
+ _LIBCPP_INLINE_VISIBILITY
+ basic_filebuf* open(const _VSTD_FS::path& __p, ios_base::openmode __mode) {
+ return open(__p.c_str(), __mode);
+ }
+ #endif
_LIBCPP_INLINE_VISIBILITY
basic_filebuf* __open(int __fd, ios_base::openmode __mode);
#endif
basic_filebuf* close();
_LIBCPP_INLINE_VISIBILITY
inline static const char*
@@ -734,15 +753,15 @@
__extbufend_ = __extbufnext_ + __nr;
char_type* __inext;
__r = __cv_->in(__st_, __extbuf_, __extbufend_, __extbufnext_,
this->eback() + __unget_sz,
this->eback() + __ibs_, __inext);
if (__r == codecvt_base::noconv)
{
- this->setg((char_type*)__extbuf_, (char_type*)__extbuf_,
+ this->setg((char_type*)__extbuf_, (char_type*)__extbuf_,
(char_type*)const_cast<char *>(__extbufend_));
__c = traits_type::to_int_type(*this->gptr());
}
else if (__inext != this->eback() + __unget_sz)
{
this->setg(this->eback(), this->eback() + __unget_sz, __inext);
__c = traits_type::to_int_type(*this->gptr());
@@ -1127,14 +1146,19 @@
explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in);
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
_LIBCPP_INLINE_VISIBILITY
explicit basic_ifstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in);
#endif
_LIBCPP_INLINE_VISIBILITY
explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
+ #if _LIBCPP_STD_VER >= 17
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_ifstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in)
+ : basic_ifstream(__p.c_str(), __mode) {}
+ #endif // _LIBCPP_STD_VER >= 17
#endif
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
basic_ifstream(basic_ifstream&& __rhs);
_LIBCPP_INLINE_VISIBILITY
basic_ifstream& operator=(basic_ifstream&& __rhs);
@@ -1148,14 +1172,21 @@
bool is_open() const;
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
void open(const char* __s, ios_base::openmode __mode = ios_base::in);
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in);
#endif
void open(const string& __s, ios_base::openmode __mode = ios_base::in);
+ #if _LIBCPP_STD_VER >= 17
+ _LIBCPP_INLINE_VISIBILITY
+ void open(const filesystem::path& __p,
+ ios_base::openmode __mode = ios_base::in) {
+ return open(__p.c_str(), __mode);
+ }
+ #endif // _LIBCPP_STD_VER >= 17
_LIBCPP_INLINE_VISIBILITY
void __open(int __fd, ios_base::openmode __mode);
#endif
_LIBCPP_INLINE_VISIBILITY
void close();
@@ -1329,14 +1360,19 @@
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
_LIBCPP_INLINE_VISIBILITY
explicit basic_ofstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::out);
#endif
_LIBCPP_INLINE_VISIBILITY
explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
+ #if _LIBCPP_STD_VER >= 17
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_ofstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out)
+ : basic_ofstream(__p.c_str(), __mode) {}
+ #endif // _LIBCPP_STD_VER >= 17
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
basic_ofstream(basic_ofstream&& __rhs);
_LIBCPP_INLINE_VISIBILITY
basic_ofstream& operator=(basic_ofstream&& __rhs);
@@ -1351,14 +1387,20 @@
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
void open(const char* __s, ios_base::openmode __mode = ios_base::out);
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::out);
#endif
void open(const string& __s, ios_base::openmode __mode = ios_base::out);
+ #if _LIBCPP_STD_VER >= 17
+ _LIBCPP_INLINE_VISIBILITY
+ void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out)
+ { return open(__p.c_str(), __mode); }
+ #endif // _LIBCPP_STD_VER >= 17
+
_LIBCPP_INLINE_VISIBILITY
void __open(int __fd, ios_base::openmode __mode);
#endif
_LIBCPP_INLINE_VISIBILITY
void close();
private:
@@ -1532,14 +1574,20 @@
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
_LIBCPP_INLINE_VISIBILITY
explicit basic_fstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
#endif
_LIBCPP_INLINE_VISIBILITY
explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+ #if _LIBCPP_STD_VER >= 17
+ _LIBCPP_INLINE_VISIBILITY
+ explicit basic_fstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in | ios_base::out)
+ : basic_fstream(__p.c_str(), __mode) {}
+ #endif // _LIBCPP_STD_VER >= 17
+
#endif
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
basic_fstream(basic_fstream&& __rhs);
_LIBCPP_INLINE_VISIBILITY
basic_fstream& operator=(basic_fstream&& __rhs);
@@ -1554,14 +1602,20 @@
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
#endif
void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+ #if _LIBCPP_STD_VER >= 17
+ _LIBCPP_INLINE_VISIBILITY
+ void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in|ios_base::out)
+ { return open(__p.c_str(), __mode); }
+ #endif // _LIBCPP_STD_VER >= 17
+
#endif
_LIBCPP_INLINE_VISIBILITY
void close();
private:
basic_filebuf<char_type, traits_type> __sb_;
};
@@ -552,22 +552,21 @@
__assoc_sub_state() : __state_(0) {}
_LIBCPP_INLINE_VISIBILITY
bool __has_value() const
{return (__state_ & __constructed) || (__exception_ != nullptr);}
_LIBCPP_INLINE_VISIBILITY
- void __attach_future() {
+ void __set_future_attached()
+ {
lock_guard<mutex> __lk(__mut_);
- bool __has_future_attached = (__state_ & __future_attached) != 0;
- if (__has_future_attached)
- __throw_future_error(future_errc::future_already_retrieved);
- this->__add_shared();
__state_ |= __future_attached;
}
+ _LIBCPP_INLINE_VISIBILITY
+ bool __has_future_attached() const {return (__state_ & __future_attached) != 0;}
_LIBCPP_INLINE_VISIBILITY
void __set_deferred() {__state_ |= deferred;}
void __make_ready();
_LIBCPP_INLINE_VISIBILITY
bool __is_ready() const {return (__state_ & ready) != 0;}
@@ -1151,15 +1150,18 @@
{return __state_->wait_until(__abs_time);}
};
template <class _Rp>
future<_Rp>::future(__assoc_state<_Rp>* __state)
: __state_(__state)
{
- __state_->__attach_future();
+ if (__state_->__has_future_attached())
+ __throw_future_error(future_errc::future_already_retrieved);
+ __state_->__add_shared();
+ __state_->__set_future_attached();
}
struct __release_shared_count
{
void operator()(__shared_count* p) {p->__release_shared();}
};
@@ -1251,15 +1253,18 @@
{return __state_->wait_until(__abs_time);}
};
template <class _Rp>
future<_Rp&>::future(__assoc_state<_Rp&>* __state)
: __state_(__state)
{
- __state_->__attach_future();
+ if (__state_->__has_future_attached())
+ __throw_future_error(future_errc::future_already_retrieved);
+ __state_->__add_shared();
+ __state_->__set_future_attached();
}
template <class _Rp>
future<_Rp&>::~future()
{
if (__state_)
__state_->__release_shared();
@@ -463,16 +463,15 @@
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
- template <class _Key, class _CP, class _Compare,
- bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value>
+ template <class _Key, class _CP, class _Compare, bool _IsSmall>
class __map_value_compare
: private _Compare
{
public:
_LIBCPP_INLINE_VISIBILITY
__map_value_compare()
_NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
@@ -878,15 +877,14 @@
typedef _Tp mapped_type;
typedef pair<const key_type, mapped_type>value_type;
typedef _Compare key_compare;
typedef _Allocator allocator_type;
typedef value_type& reference;
typedef const value_type&const_reference;
- static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
class _LIBCPP_TEMPLATE_VIS value_compare
: public binary_function<value_type, value_type, bool>
{
friend class map;
@@ -1568,15 +1566,14 @@
typedef _Tp mapped_type;
typedef pair<const key_type, mapped_type>value_type;
typedef _Compare key_compare;
typedef _Allocator allocator_type;
typedef value_type& reference;
typedef const value_type&const_reference;
- static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
class _LIBCPP_TEMPLATE_VIS value_compare
: public binary_function<value_type, value_type, bool>
{
friend class multimap;
@@ -1455,29 +1455,37 @@
decltype(_VSTD::__has_select_on_container_copy_construction_test(declval<_Alloc&>())),
true_type>::value>
{
};
#else // _LIBCPP_CXX03_LANG
- template <class _Alloc, class _Pointer, class _Tp, class = void>
- struct __has_construct : std::false_type {};
+ #ifndef _LIBCPP_HAS_NO_VARIADICS
- template <class _Alloc, class _Pointer, class _Tp>
- struct __has_construct<_Alloc, _Pointer, _Tp, typename __void_t<
- decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Pointer>(), _VSTD::declval<_Tp>()))
- >::type> : std::true_type {};
+ template <class _Alloc, class _Pointer, class ..._Args>
+ struct __has_construct
+ : false_type
+ {
+ };
- template <class _Alloc, class _Pointer, class = void>
- struct __has_destroy : false_type {};
+ #else // _LIBCPP_HAS_NO_VARIADICS
+
+ template <class _Alloc, class _Pointer, class _Args>
+ struct __has_construct
+ : false_type
+ {
+ };
+
+ #endif // _LIBCPP_HAS_NO_VARIADICS
template <class _Alloc, class _Pointer>
- struct __has_destroy<_Alloc, _Pointer, typename __void_t<
- decltype(_VSTD::declval<_Alloc>().destroy(_VSTD::declval<_Pointer>()))
- >::type> : std::true_type {};
+ struct __has_destroy
+ : false_type
+ {
+ };
template <class _Alloc>
struct __has_max_size
: true_type
{
};
@@ -1497,20 +1505,14 @@
template <class _Alloc, class _Ptr>
struct __alloc_traits_difference_type<_Alloc, _Ptr, true>
{
typedef typename _Alloc::difference_type type;
};
- template <class _Tp>
- struct __is_default_allocator : false_type {};
-
- template <class _Tp>
- struct __is_default_allocator<_VSTD::allocator<_Tp> > : true_type {};
-
template <class _Alloc>
struct _LIBCPP_TEMPLATE_VIS allocator_traits
{
typedef _Alloc allocator_type;
typedef typename allocator_type::value_type value_type;
typedef typename __pointer_type<value_type, allocator_type>::type pointer;
@@ -1564,18 +1566,17 @@
_LIBCPP_INLINE_VISIBILITY
static void construct(allocator_type&, _Tp* __p)
{
::new ((void*)__p) _Tp();
}
template <class _Tp, class _A0>
_LIBCPP_INLINE_VISIBILITY
- static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0)
+ static void construct(allocator_type&, _Tp* __p, const _A0& __a0)
{
- __construct(__has_construct<allocator_type, _Tp*, const _A0&>(),
- __a, __p, __a0);
+ ::new ((void*)__p) _Tp(__a0);
}
template <class _Tp, class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
static void construct(allocator_type&, _Tp* __p, const _A0& __a0,
const _A1& __a1)
{
::new ((void*)__p) _Tp(__a0, __a1);
@@ -1616,15 +1617,15 @@
}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
static
typename enable_if
<
- (__is_default_allocator<allocator_type>::value
+ (is_same<allocator_type, allocator<_Tp> >::value
|| !__has_construct<allocator_type, _Tp*, _Tp>::value) &&
is_trivially_move_constructible<_Tp>::value,
void
>::type
__construct_forward(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
{
ptrdiff_t _Np = __end1 - __begin1;
@@ -1641,33 +1642,31 @@
void
__construct_range_forward(allocator_type& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2)
{
for (; __begin1 != __end1; ++__begin1, (void) ++__begin2)
construct(__a, _VSTD::__to_raw_pointer(__begin2), *__begin1);
}
- template <class _SourceTp, class _DestTp,
- class _RawSourceTp = typename remove_const<_SourceTp>::type,
- class _RawDestTp = typename remove_const<_DestTp>::type>
+ template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
static
typename enable_if
<
- is_trivially_move_constructible<_DestTp>::value &&
- is_same<_RawSourceTp, _RawDestTp>::value &&
- (__is_default_allocator<allocator_type>::value ||
- !__has_construct<allocator_type, _DestTp*, _SourceTp&>::value),
+ (is_same<allocator_type, allocator<_Tp> >::value
+ || !__has_construct<allocator_type, _Tp*, _Tp>::value) &&
+ is_trivially_move_constructible<_Tp>::value,
void
>::type
- __construct_range_forward(allocator_type&, _SourceTp* __begin1, _SourceTp* __end1, _DestTp*& __begin2)
+ __construct_range_forward(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
{
+ typedef typename remove_const<_Tp>::type _Vp;
ptrdiff_t _Np = __end1 - __begin1;
if (_Np > 0)
{
- _VSTD::memcpy(const_cast<_RawDestTp*>(__begin2), __begin1, _Np * sizeof(_DestTp));
+ _VSTD::memcpy(const_cast<_Vp*>(__begin2), __begin1, _Np * sizeof(_Tp));
__begin2 += _Np;
}
}
template <class _Ptr>
_LIBCPP_INLINE_VISIBILITY
static
@@ -1682,15 +1681,15 @@
}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
static
typename enable_if
<
- (__is_default_allocator<allocator_type>::value
+ (is_same<allocator_type, allocator<_Tp> >::value
|| !__has_construct<allocator_type, _Tp*, _Tp>::value) &&
is_trivially_move_constructible<_Tp>::value,
void
>::type
__construct_backward(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __end2)
{
ptrdiff_t _Np = __end1 - __begin1;
@@ -1717,27 +1716,14 @@
{__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
template <class _Tp, class... _Args>
_LIBCPP_INLINE_VISIBILITY
static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args)
{
::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...);
}
- #else // _LIBCPP_HAS_NO_VARIADICS
- template <class _Tp, class _A0>
- _LIBCPP_INLINE_VISIBILITY
- static void __construct(true_type, allocator_type& __a, _Tp* __p,
- const _A0& __a0)
- {__a.construct(__p, __a0);}
- template <class _Tp, class _A0>
- _LIBCPP_INLINE_VISIBILITY
- static void __construct(false_type, allocator_type&, _Tp* __p,
- const _A0& __a0)
- {
- ::new ((void*)__p) _Tp(__a0);
- }
#endif // _LIBCPP_HAS_NO_VARIADICS
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
static void __destroy(true_type, allocator_type& __a, _Tp* __p)
{__a.destroy(__p);}
template <class _Tp>
@@ -264,14 +264,18 @@
export initializer_list
export *
}
module exception {
header "exception"
export *
}
+ module filesystem {
+ header "filesystem"
+ export *
+ }
module forward_list {
header "forward_list"
export initializer_list
export *
}
module fstream {
header "fstream"
@@ -516,14 +520,18 @@
header "experimental/deque"
export *
}
module dynarray {
header "experimental/dynarray"
export *
}
+ module filesystem {
+ header "experimental/filesystem"
+ export *
+ }
module forward_list {
header "experimental/forward_list"
export *
}
module functional {
header "experimental/functional"
export *
@@ -164,15 +164,15 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
namespace std // purposefully not using versioning namespace
{
- class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access
+ class _LIBCPP_EXCEPTION_ABI bad_optional_access
: public exception
{
public:
// Get the key function ~bad_optional_access() into the dylib
virtual ~bad_optional_access() _NOEXCEPT;
virtual const char* what() const _NOEXCEPT;
};
@@ -181,15 +181,14 @@
#if _LIBCPP_STD_VER > 14
_LIBCPP_BEGIN_NAMESPACE_STD
_LIBCPP_NORETURN
inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
void __throw_bad_optional_access() {
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_optional_access();
#else
_VSTD::abort();
#endif
}
@@ -929,42 +928,38 @@
_LIBCPP_INLINE_VISIBILITY
constexpr explicit operator bool() const noexcept { return has_value(); }
using __base::has_value;
using __base::__get;
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
constexpr value_type const& value() const&
{
if (!this->has_value())
__throw_bad_optional_access();
return this->__get();
}
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
constexpr value_type& value() &
{
if (!this->has_value())
__throw_bad_optional_access();
return this->__get();
}
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
constexpr value_type&& value() &&
{
if (!this->has_value())
__throw_bad_optional_access();
return _VSTD::move(this->__get());
}
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
constexpr value_type const&& value() const&&
{
if (!this->has_value())
__throw_bad_optional_access();
return _VSTD::move(this->__get());
}
@@ -419,15 +419,14 @@
typedef key_type value_type;
typedef _Compare key_compare;
typedef key_compare value_compare;
typedef _Allocator allocator_type;
typedef value_type& reference;
typedef const value_type&const_reference;
- static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
private:
typedef __tree<value_type, value_compare, allocator_type> __base;
typedef allocator_traits<allocator_type> __alloc_traits;
typedef typename __base::__node_holder__node_holder;
@@ -863,15 +862,14 @@
typedef key_type value_type;
typedef _Compare key_compare;
typedef key_compare value_compare;
typedef _Allocatorallocator_type;
typedef value_type& reference;
typedef const value_type&const_reference;
- static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
private:
typedef __tree<value_type, value_compare, allocator_type> __base;
typedef allocator_traits<allocator_type> __alloc_traits;
typedef typename __base::__node_holder__node_holder;
@@ -773,20 +773,25 @@
typedef basic_string_view<wchar_t> wstring_view;
// [string.view.hash]
template<class _CharT, class _Traits>
struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, _Traits> >
: public unary_function<basic_string_view<_CharT, _Traits>, size_t>
{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(const basic_string_view<_CharT, _Traits> __val) const _NOEXCEPT {
- return __do_string_hash(__val.data(), __val.data() + __val.size());
- }
+ size_t operator()(const basic_string_view<_CharT, _Traits> __val) const _NOEXCEPT;
};
+ template<class _CharT, class _Traits>
+ size_t
+ hash<basic_string_view<_CharT, _Traits> >::operator()(
+ const basic_string_view<_CharT, _Traits> __val) const _NOEXCEPT
+ {
+ return __do_string_hash(__val.data(), __val.data() + __val.size());
+ }
+
#if _LIBCPP_STD_VER > 11
inline namespace literals
{
inline namespace string_view_literals
{
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
@@ -729,14 +729,20 @@
_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v
= is_integral<_Tp>::value;
#endif
// is_floating_point
template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
+ #ifdef __clang__
+ template <> struct __libcpp_is_floating_point<__fp16> : public true_type {};
+ #endif
+ #ifdef __FLT16_MANT_DIG__
+ template <> struct __libcpp_is_floating_point<_Float16>: public true_type {};
+ #endif
template <> struct __libcpp_is_floating_point<float> : public true_type {};
template <> struct __libcpp_is_floating_point<double> : public true_type {};
template <> struct __libcpp_is_floating_point<long double> : public true_type {};
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
: public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
@@ -391,16 +391,15 @@
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
- template <class _Key, class _Cp, class _Hash,
- bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>
+ template <class _Key, class _Cp, class _Hash, bool _IsEmpty>
class __unordered_map_hasher
: private _Hash
{
public:
_LIBCPP_INLINE_VISIBILITY
__unordered_map_hasher()
_NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
@@ -460,16 +459,15 @@
swap(__unordered_map_hasher<_Key, _Cp, _Hash, __b>& __x,
__unordered_map_hasher<_Key, _Cp, _Hash, __b>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
{
__x.swap(__y);
}
- template <class _Key, class _Cp, class _Pred,
- bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value>
+ template <class _Key, class _Cp, class _Pred, bool _IsEmpty>
class __unordered_map_equal
: private _Pred
{
public:
_LIBCPP_INLINE_VISIBILITY
__unordered_map_equal()
_NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
@@ -821,15 +819,14 @@
typedef _Pred key_equal;
typedef _Alloc allocator_type;
typedef pair<const key_type, mapped_type> value_type;
typedef value_type&reference;
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
"Invalid allocator::value_type");
- static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
private:
typedef __hash_value_type<key_type, mapped_type> __value_type;
typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;
typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
__value_type>::type __allocator_type;
@@ -1606,15 +1603,14 @@
typedef _Pred key_equal;
typedef _Alloc allocator_type;
typedef pair<const key_type, mapped_type> value_type;
typedef value_type&reference;
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
"Invalid allocator::value_type");
- static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
private:
typedef __hash_value_type<key_type, mapped_type> __value_type;
typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;
typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
__value_type>::type __allocator_type;
@@ -358,15 +358,14 @@
typedef _Hash hasher;
typedef _Pred key_equal;
typedef _Alloc allocator_type;
typedef value_type&reference;
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
"Invalid allocator::value_type");
- static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
private:
typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
__table __table_;
public:
@@ -913,15 +912,14 @@
typedef _Hash hasher;
typedef _Pred key_equal;
typedef _Alloc allocator_type;
typedef value_type&reference;
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
"Invalid allocator::value_type");
- static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
private:
typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
__table __table_;
public:
@@ -404,88 +404,70 @@
__check_tuple_constructor_fail
>::type;
template<bool _Dummy = true, _EnableB<
_CheckArgsDep<_Dummy>::template __enable_default<_T1, _T2>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
- is_nothrow_default_constructible<second_type>::value)
- : first(), second() {}
+ pair() : first(), second() {}
template <bool _Dummy = true, _EnableB<
_CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit pair(_T1 const& __t1, _T2 const& __t2)
- _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
- is_nothrow_copy_constructible<second_type>::value)
: first(__t1), second(__t2) {}
template<bool _Dummy = true, _EnableB<
_CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(_T1 const& __t1, _T2 const& __t2)
- _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
- is_nothrow_copy_constructible<second_type>::value)
: first(__t1), second(__t2) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_explicit<_U1, _U2>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit pair(_U1&& __u1, _U2&& __u2)
- _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
- is_nothrow_constructible<second_type, _U2>::value))
: first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_implicit<_U1, _U2>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(_U1&& __u1, _U2&& __u2)
- _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
- is_nothrow_constructible<second_type, _U2>::value))
: first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit pair(pair<_U1, _U2> const& __p)
- _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
- is_nothrow_constructible<second_type, _U2 const&>::value))
: first(__p.first), second(__p.second) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(pair<_U1, _U2> const& __p)
- _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
- is_nothrow_constructible<second_type, _U2 const&>::value))
: first(__p.first), second(__p.second) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_explicit<_U1, _U2>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit pair(pair<_U1, _U2>&&__p)
- _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
- is_nothrow_constructible<second_type, _U2&&>::value))
: first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_implicit<_U1, _U2>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(pair<_U1, _U2>&& __p)
- _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
- is_nothrow_constructible<second_type, _U2&&>::value))
: first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {}
template<class _Tuple, _EnableB<
_CheckTLC<_Tuple>::template __enable_explicit<_Tuple>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit pair(_Tuple&& __p)
@@ -500,16 +482,14 @@
: first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))),
second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}
template <class... _Args1, class... _Args2>
_LIBCPP_INLINE_VISIBILITY
pair(piecewise_construct_t __pc,
tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)
- _NOEXCEPT_((is_nothrow_constructible<first_type, _Args1...>::value &&
- is_nothrow_constructible<second_type, _Args2...>::value))
: pair(__pc, __first_args, __second_args,
typename __make_tuple_indices<sizeof...(_Args1)>::type(),
typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}
_LIBCPP_INLINE_VISIBILITY
pair& operator=(typename conditional<
is_copy_assignable<first_type>::value &&
@@ -214,28 +214,27 @@
#endif
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
namespace std { // explicitly not using versioning namespace
- class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS bad_variant_access : public exception {
+ class _LIBCPP_EXCEPTION_ABI bad_variant_access : public exception {
public:
virtual const char* what() const _NOEXCEPT;
};
} // namespace std
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 14
_LIBCPP_NORETURN
inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
void __throw_bad_variant_access() {
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_variant_access();
#else
_VSTD::abort();
#endif
}
@@ -1317,91 +1316,82 @@
inline _LIBCPP_INLINE_VISIBILITY
constexpr bool holds_alternative(const variant<_Types...>& __v) noexcept {
return __holds_alternative<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
}
template <size_t _Ip, class _Vp>
inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
static constexpr auto&& __generic_get(_Vp&& __v) {
using __variant_detail::__access::__variant;
if (!__holds_alternative<_Ip>(__v)) {
__throw_bad_variant_access();
}
return __variant::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v)).__value;
}
template <size_t _Ip, class... _Types>
inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr variant_alternative_t<_Ip, variant<_Types...>>& get(
variant<_Types...>& __v) {
static_assert(_Ip < sizeof...(_Types));
static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
return __generic_get<_Ip>(__v);
}
template <size_t _Ip, class... _Types>
inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr variant_alternative_t<_Ip, variant<_Types...>>&& get(
variant<_Types...>&& __v) {
static_assert(_Ip < sizeof...(_Types));
static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
return __generic_get<_Ip>(_VSTD::move(__v));
}
template <size_t _Ip, class... _Types>
inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr const variant_alternative_t<_Ip, variant<_Types...>>& get(
const variant<_Types...>& __v) {
static_assert(_Ip < sizeof...(_Types));
static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
return __generic_get<_Ip>(__v);
}
template <size_t _Ip, class... _Types>
inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& get(
const variant<_Types...>&& __v) {
static_assert(_Ip < sizeof...(_Types));
static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
return __generic_get<_Ip>(_VSTD::move(__v));
}
template <class _Tp, class... _Types>
inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr _Tp& get(variant<_Types...>& __v) {
static_assert(!is_void_v<_Tp>);
return _VSTD::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
}
template <class _Tp, class... _Types>
inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr _Tp&& get(variant<_Types...>&& __v) {
static_assert(!is_void_v<_Tp>);
return _VSTD::get<__find_exactly_one_t<_Tp, _Types...>::value>(
_VSTD::move(__v));
}
template <class _Tp, class... _Types>
inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr const _Tp& get(const variant<_Types...>& __v) {
static_assert(!is_void_v<_Tp>);
return _VSTD::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
}
template <class _Tp, class... _Types>
inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr const _Tp&& get(const variant<_Types...>&& __v) {
static_assert(!is_void_v<_Tp>);
return _VSTD::get<__find_exactly_one_t<_Tp, _Types...>::value>(
_VSTD::move(__v));
}
template <size_t _Ip, class _Vp>
@@ -1516,15 +1506,14 @@
if (__lhs.index() < __rhs.index()) return false;
return __variant::__visit_value_at(
__lhs.index(), greater_equal<>{}, __lhs, __rhs);
}
template <class _Visitor, class... _Vs>
inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) {
using __variant_detail::__visitation::__variant;
bool __results[] = {__vs.valueless_by_exception()...};
for (bool __result : __results) {
if (__result) {
__throw_bad_variant_access();
}