Skip to content

Commit

Permalink
Import libstdc++ include directory from arm gcc 10.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-durand authored and salkinium committed Jan 10, 2021
1 parent ec849a2 commit 4fd647b
Show file tree
Hide file tree
Showing 741 changed files with 241,999 additions and 6,469 deletions.
20 changes: 19 additions & 1 deletion include/algorithm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// <algorithm> -*- C++ -*-

// Copyright (C) 2001-2018 Free Software Foundation, Inc.
// Copyright (C) 2001-2020 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
Expand Down Expand Up @@ -60,6 +60,24 @@
#include <utility> // UK-300.
#include <bits/stl_algobase.h>
#include <bits/stl_algo.h>
#if __cplusplus > 201703L
# include <bits/ranges_algo.h>
#endif

#if __cplusplus > 201402L
// Parallel STL algorithms
# if _PSTL_EXECUTION_POLICIES_DEFINED
// If <execution> has already been included, pull in implementations
# include <pstl/glue_algorithm_impl.h>
# else
// Otherwise just pull in forward declarations
# include <pstl/glue_algorithm_defs.h>
# define _PSTL_ALGORITHM_FORWARD_DECLARED 1
# endif

// Feature test macro for parallel algorithms
# define __cpp_lib_parallel_algorithm 201603L
#endif // C++17

#ifdef _GLIBCXX_PARALLEL
# include <parallel/algorithm>
Expand Down
203 changes: 116 additions & 87 deletions include/any
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// <any> -*- C++ -*-

// Copyright (C) 2014-2018 Free Software Foundation, Inc.
// Copyright (C) 2014-2020 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
Expand Down Expand Up @@ -33,14 +33,10 @@

#if __cplusplus >= 201703L

#ifdef __cpp_rtti
#include <typeinfo>
#endif

#include <typeinfo>
#include <new>
#include <utility>
#include <type_traits>
#include <bits/functexcept.h>

namespace std _GLIBCXX_VISIBILITY(default)
{
Expand All @@ -51,7 +47,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @{
*/

#define __cpp_lib_any 201603
/**
* @brief Exception class thrown by a failed @c any_cast
* @ingroup exceptions
*/
class bad_any_cast : public bad_cast
{
public:
virtual const char* what() const noexcept { return "bad any_cast"; }
};

[[gnu::noreturn]] inline void __throw_bad_any_cast()
{
#if __cpp_exceptions
throw bad_any_cast{};
#else
__builtin_abort();
#endif
}

#define __cpp_lib_any 201606L

/**
* @brief A type-safe container of any type.
Expand Down Expand Up @@ -90,8 +105,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Manager_internal<_Tp>,
_Manager_external<_Tp>>;

template<typename _Tp, typename _Decayed = decay_t<_Tp>>
using _Decay = enable_if_t<!is_same<_Decayed, any>::value, _Decayed>;
template<typename _Tp, typename _VTp = decay_t<_Tp>>
using _Decay_if_not_any = enable_if_t<!is_same_v<_VTp, any>, _VTp>;

/// Emplace with an object created from @p __args as the contained object.
template <typename _Tp, typename... _Args,
Expand All @@ -110,10 +125,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void __do_emplace(initializer_list<_Up> __il, _Args&&... __args)
{
reset();
_Mgr::_S_create(_M_storage, __il, std::forward<_Args>(__args)...);
_Mgr::_S_create(_M_storage, __il, std::forward<_Args>(__args)...);
_M_manager = &_Mgr::_S_manage;
}

template <typename _Res, typename _Tp, typename... _Args>
using __any_constructible
= enable_if<__and_<is_copy_constructible<_Tp>,
is_constructible<_Tp, _Args...>>::value,
_Res>;

template <typename _Tp, typename... _Args>
using __any_constructible_t
= typename __any_constructible<bool, _Tp, _Args...>::type;

template<typename _VTp, typename... _Args>
using __emplace_t
= typename __any_constructible<_VTp&, _VTp, _Args...>::type;

public:
// construct/destruct

Expand Down Expand Up @@ -150,65 +179,39 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
}

template <typename _Res, typename _Tp, typename... _Args>
using __any_constructible =
enable_if<__and_<is_copy_constructible<_Tp>,
is_constructible<_Tp, _Args...>>::value,
_Res>;

template <typename _Tp, typename... _Args>
using __any_constructible_t =
typename __any_constructible<bool, _Tp, _Args...>::type;

/// Construct with a copy of @p __value as the contained object.
template <typename _ValueType, typename _Tp = _Decay<_ValueType>,
typename _Mgr = _Manager<_Tp>,
__any_constructible_t<_Tp, _ValueType&&> = true,
enable_if_t<!__is_in_place_type<_Tp>::value, bool> = true>
any(_ValueType&& __value)
template <typename _Tp, typename _VTp = _Decay_if_not_any<_Tp>,
typename _Mgr = _Manager<_VTp>,
enable_if_t<is_copy_constructible<_VTp>::value
&& !__is_in_place_type<_VTp>::value, bool> = true>
any(_Tp&& __value)
: _M_manager(&_Mgr::_S_manage)
{
_Mgr::_S_create(_M_storage, std::forward<_ValueType>(__value));
}

/// Construct with a copy of @p __value as the contained object.
template <typename _ValueType, typename _Tp = _Decay<_ValueType>,
typename _Mgr = _Manager<_Tp>,
enable_if_t<__and_<is_copy_constructible<_Tp>,
__not_<is_constructible<_Tp, _ValueType&&>>,
__not_<__is_in_place_type<_Tp>>>::value,
bool> = false>
any(_ValueType&& __value)
: _M_manager(&_Mgr::_S_manage)
{
_Mgr::_S_create(_M_storage, __value);
_Mgr::_S_create(_M_storage, std::forward<_Tp>(__value));
}

/// Construct with an object created from @p __args as the contained object.
template <typename _ValueType, typename... _Args,
typename _Tp = _Decay<_ValueType>,
typename _Mgr = _Manager<_Tp>,
__any_constructible_t<_Tp, _Args&&...> = false>
template <typename _Tp, typename... _Args, typename _VTp = decay_t<_Tp>,
typename _Mgr = _Manager<_VTp>,
__any_constructible_t<_VTp, _Args&&...> = false>
explicit
any(in_place_type_t<_ValueType>, _Args&&... __args)
any(in_place_type_t<_Tp>, _Args&&... __args)
: _M_manager(&_Mgr::_S_manage)
{
_Mgr::_S_create(_M_storage, std::forward<_Args>(__args)...);
_Mgr::_S_create(_M_storage, std::forward<_Args>(__args)...);
}

/// Construct with an object created from @p __il and @p __args as
/// the contained object.
template <typename _ValueType, typename _Up, typename... _Args,
typename _Tp = _Decay<_ValueType>,
typename _Mgr = _Manager<_Tp>,
__any_constructible_t<_Tp, initializer_list<_Up>,
template <typename _Tp, typename _Up, typename... _Args,
typename _VTp = decay_t<_Tp>, typename _Mgr = _Manager<_VTp>,
__any_constructible_t<_VTp, initializer_list<_Up>,
_Args&&...> = false>
explicit
any(in_place_type_t<_ValueType>,
initializer_list<_Up> __il, _Args&&... __args)
any(in_place_type_t<_Tp>, initializer_list<_Up> __il, _Args&&... __args)
: _M_manager(&_Mgr::_S_manage)
{
_Mgr::_S_create(_M_storage, __il, std::forward<_Args>(__args)...);
_Mgr::_S_create(_M_storage, __il, std::forward<_Args>(__args)...);
}

/// Destructor, calls @c reset()
Expand All @@ -217,7 +220,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// assignments

/// Copy the state of another object.
any& operator=(const any& __rhs)
any&
operator=(const any& __rhs)
{
*this = any(__rhs);
return *this;
Expand All @@ -228,7 +232,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*
* @post @c !__rhs.has_value() (not guaranteed for other implementations)
*/
any& operator=(any&& __rhs) noexcept
any&
operator=(any&& __rhs) noexcept
{
if (!__rhs.has_value())
reset();
Expand All @@ -243,40 +248,37 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}

/// Store a copy of @p __rhs as the contained object.
template<typename _ValueType>
enable_if_t<is_copy_constructible<_Decay<_ValueType>>::value, any&>
operator=(_ValueType&& __rhs)
template<typename _Tp>
enable_if_t<is_copy_constructible<_Decay_if_not_any<_Tp>>::value, any&>
operator=(_Tp&& __rhs)
{
*this = any(std::forward<_ValueType>(__rhs));
*this = any(std::forward<_Tp>(__rhs));
return *this;
}

/// Emplace with an object created from @p __args as the contained object.
template <typename _ValueType, typename... _Args>
typename __any_constructible<_Decay<_ValueType>&,
_Decay<_ValueType>, _Args&&...>::type
template <typename _Tp, typename... _Args>
__emplace_t<decay_t<_Tp>, _Args...>
emplace(_Args&&... __args)
{
__do_emplace<_Decay<_ValueType>>(std::forward<_Args>(__args)...);
using _VTp = decay_t<_Tp>;
__do_emplace<_VTp>(std::forward<_Args>(__args)...);
any::_Arg __arg;
this->_M_manager(any::_Op_access, this, &__arg);
return *static_cast<_Decay<_ValueType>*>(__arg._M_obj);
return *static_cast<_VTp*>(__arg._M_obj);
}

/// Emplace with an object created from @p __il and @p __args as
/// the contained object.
template <typename _ValueType, typename _Up, typename... _Args>
typename __any_constructible<_Decay<_ValueType>&,
_Decay<_ValueType>,
initializer_list<_Up>,
_Args&&...>::type
template <typename _Tp, typename _Up, typename... _Args>
__emplace_t<decay_t<_Tp>, initializer_list<_Up>, _Args&&...>
emplace(initializer_list<_Up> __il, _Args&&... __args)
{
__do_emplace<_Decay<_ValueType>, _Up>(__il,
std::forward<_Args>(__args)...);
using _VTp = decay_t<_Tp>;
__do_emplace<_VTp, _Up>(__il, std::forward<_Args>(__args)...);
any::_Arg __arg;
this->_M_manager(any::_Op_access, this, &__arg);
return *static_cast<_Decay<_ValueType>*>(__arg._M_obj);
return *static_cast<_VTp*>(__arg._M_obj);
}

// modifiers
Expand Down Expand Up @@ -436,7 +438,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _ValueType>
inline _ValueType any_cast(const any& __any)
{
using _Up = remove_cv_t<remove_reference_t<_ValueType>>;
using _Up = __remove_cvref_t<_ValueType>;
static_assert(any::__is_valid_cast<_ValueType>(),
"Template argument must be a reference or CopyConstructible type");
static_assert(is_constructible_v<_ValueType, const _Up&>,
Expand All @@ -462,7 +464,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _ValueType>
inline _ValueType any_cast(any& __any)
{
using _Up = remove_cv_t<remove_reference_t<_ValueType>>;
using _Up = __remove_cvref_t<_ValueType>;
static_assert(any::__is_valid_cast<_ValueType>(),
"Template argument must be a reference or CopyConstructible type");
static_assert(is_constructible_v<_ValueType, _Up&>,
Expand All @@ -476,7 +478,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _ValueType>
inline _ValueType any_cast(any&& __any)
{
using _Up = remove_cv_t<remove_reference_t<_ValueType>>;
using _Up = __remove_cvref_t<_ValueType>;
static_assert(any::__is_valid_cast<_ValueType>(),
"Template argument must be a reference or CopyConstructible type");
static_assert(is_constructible_v<_ValueType, _Up>,
Expand All @@ -488,20 +490,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
// @}

/// @cond undocumented
template<typename _Tp>
void* __any_caster(const any* __any)
{
if constexpr (is_copy_constructible_v<decay_t<_Tp>>)
// any_cast<T> returns non-null if __any->type() == typeid(T) and
// typeid(T) ignores cv-qualifiers so remove them:
using _Up = remove_cv_t<_Tp>;
// The contained value has a decayed type, so if decay_t<U> is not U,
// then it's not possible to have a contained value of type U:
if constexpr (!is_same_v<decay_t<_Up>, _Up>)
return nullptr;
// Only copy constructible types can be used for contained values:
else if constexpr (!is_copy_constructible_v<_Up>)
return nullptr;
// First try comparing function addresses, which works without RTTI
else if (__any->_M_manager == &any::_Manager<_Up>::_S_manage
#if __cpp_rtti
|| __any->type() == typeid(_Tp)
#endif
)
{
if (__any->_M_manager == &any::_Manager<decay_t<_Tp>>::_S_manage)
{
any::_Arg __arg;
__any->_M_manager(any::_Op_access, __any, &__arg);
return __arg._M_obj;
}
any::_Arg __arg;
__any->_M_manager(any::_Op_access, __any, &__arg);
return __arg._M_obj;
}
return nullptr;
}
/// @endcond

/**
* @brief Access the contained object.
Expand All @@ -517,16 +533,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _ValueType>
inline const _ValueType* any_cast(const any* __any) noexcept
{
if (__any)
return static_cast<_ValueType*>(__any_caster<_ValueType>(__any));
if constexpr (is_object_v<_ValueType>)
if (__any)
return static_cast<_ValueType*>(__any_caster<_ValueType>(__any));
return nullptr;
}

template<typename _ValueType>
inline _ValueType* any_cast(any* __any) noexcept
{
if (__any)
return static_cast<_ValueType*>(__any_caster<_ValueType>(__any));
if constexpr (is_object_v<_ValueType>)
if (__any)
return static_cast<_ValueType*>(__any_caster<_ValueType>(__any));
return nullptr;
}
// @}
Expand Down Expand Up @@ -599,9 +617,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION

/// @}

namespace __detail::__variant
{
template<typename> struct _Never_valueless_alt; // see <variant>

// Provide the strong exception-safety guarantee when emplacing an
// any into a variant.
template<>
struct _Never_valueless_alt<std::any>
: std::true_type
{ };
} // namespace __detail::__variant

_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std

#endif // C++14

#endif // C++17
#endif // _GLIBCXX_ANY
Loading

0 comments on commit 4fd647b

Please sign in to comment.