diff options
author | Louis Dionne <ldionne.2@gmail.com> | 2023-12-18 14:01:33 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-18 14:01:33 -0500 |
commit | 9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7 (patch) | |
tree | 4119e3edc01dd51cf2752b2a3341c34d8a3700ac /libcxx/include/experimental | |
parent | e5c523e8610492b3256dde6856811b527b4dcb35 (diff) | |
download | llvm-9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7.zip llvm-9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7.tar.gz llvm-9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7.tar.bz2 |
[libc++] Format the code base (#74334)
This patch runs clang-format on all of libcxx/include and libcxx/src, in
accordance with the RFC discussed at [1]. Follow-up patches will format
the benchmarks, the test suite and remaining parts of the code. I'm
splitting this one into its own patch so the diff is a bit easier to
review.
This patch was generated with:
find libcxx/include libcxx/src -type f \
| grep -v 'module.modulemap.in' \
| grep -v 'CMakeLists.txt' \
| grep -v 'README.txt' \
| grep -v 'libcxx.imp' \
| grep -v '__config_site.in' \
| xargs clang-format -i
A Git merge driver is available in libcxx/utils/clang-format-merge-driver.sh
to help resolve merge and rebase issues across these formatting changes.
[1]: https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
Diffstat (limited to 'libcxx/include/experimental')
-rw-r--r-- | libcxx/include/experimental/__config | 22 | ||||
-rw-r--r-- | libcxx/include/experimental/__memory | 90 | ||||
-rw-r--r-- | libcxx/include/experimental/iterator | 69 | ||||
-rw-r--r-- | libcxx/include/experimental/propagate_const | 305 | ||||
-rw-r--r-- | libcxx/include/experimental/type_traits | 69 | ||||
-rw-r--r-- | libcxx/include/experimental/utility | 2 |
6 files changed, 215 insertions, 342 deletions
diff --git a/libcxx/include/experimental/__config b/libcxx/include/experimental/__config index 8bc4f5d..7b23791 100644 --- a/libcxx/include/experimental/__config +++ b/libcxx/include/experimental/__config @@ -16,20 +16,30 @@ # pragma GCC system_header #endif -#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental { -#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL } } +#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL \ + namespace std { \ + namespace experimental { +#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL \ + } \ + } #define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 { -#define _LIBCPP_END_NAMESPACE_LFTS } } } +#define _LIBCPP_END_NAMESPACE_LFTS \ + } \ + } \ + } #define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 { -#define _LIBCPP_END_NAMESPACE_LFTS_V2 } } } +#define _LIBCPP_END_NAMESPACE_LFTS_V2 \ + } \ + } \ + } // TODO: support more targets #if defined(__AVX__) -#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32 +# define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32 #else -#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16 +# define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16 #endif #endif diff --git a/libcxx/include/experimental/__memory b/libcxx/include/experimental/__memory index fb82922..b9dbf54 100644 --- a/libcxx/include/experimental/__memory +++ b/libcxx/include/experimental/__memory @@ -25,11 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS -template < - class _Tp, class _Alloc - , bool = uses_allocator<_Tp, _Alloc>::value - , bool = __has_allocator_type<_Tp>::value - > +template < class _Tp, class _Alloc, bool = uses_allocator<_Tp, _Alloc>::value, bool = __has_allocator_type<_Tp>::value > struct __lfts_uses_allocator : public false_type {}; template <class _Tp, class _Alloc> @@ -40,79 +36,57 @@ struct __lfts_uses_allocator<_Tp, _Alloc, true, HasAlloc> : public true_type {}; template <class _Tp, class _Alloc> struct __lfts_uses_allocator<_Tp, _Alloc, false, true> - : public integral_constant<bool - , is_convertible<_Alloc, typename _Tp::allocator_type>::value - || is_same<erased_type, typename _Tp::allocator_type>::value - > -{}; - -template <bool _UsesAlloc, class _Tp, class _Alloc, class ..._Args> -struct __lfts_uses_alloc_ctor_imp -{ - static const int value = 0; + : public integral_constant<bool, + is_convertible<_Alloc, typename _Tp::allocator_type>::value || + is_same<erased_type, typename _Tp::allocator_type>::value > {}; + +template <bool _UsesAlloc, class _Tp, class _Alloc, class... _Args> +struct __lfts_uses_alloc_ctor_imp { + static const int value = 0; }; -template <class _Tp, class _Alloc, class ..._Args> -struct __lfts_uses_alloc_ctor_imp<true, _Tp, _Alloc, _Args...> -{ - static const bool __ic_first - = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; +template <class _Tp, class _Alloc, class... _Args> +struct __lfts_uses_alloc_ctor_imp<true, _Tp, _Alloc, _Args...> { + static const bool __ic_first = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; - static const bool __ic_second = - __conditional_t< - __ic_first, - false_type, - is_constructible<_Tp, _Args..., _Alloc> - >::value; + static const bool __ic_second = + __conditional_t< __ic_first, false_type, is_constructible<_Tp, _Args..., _Alloc> >::value; - static_assert(__ic_first || __ic_second, - "Request for uses allocator construction is ill-formed"); + static_assert(__ic_first || __ic_second, "Request for uses allocator construction is ill-formed"); - static const int value = __ic_first ? 1 : 2; + static const int value = __ic_first ? 1 : 2; }; -template <class _Tp, class _Alloc, class ..._Args> +template <class _Tp, class _Alloc, class... _Args> struct __lfts_uses_alloc_ctor - : integral_constant<int, - __lfts_uses_alloc_ctor_imp< - __lfts_uses_allocator<_Tp, _Alloc>::value - , _Tp, _Alloc, _Args... - >::value - > -{}; + : integral_constant< + int, + __lfts_uses_alloc_ctor_imp< __lfts_uses_allocator<_Tp, _Alloc>::value, _Tp, _Alloc, _Args... >::value > {}; template <class _Tp, class _Allocator, class... _Args> -inline _LIBCPP_HIDE_FROM_ABI -void __user_alloc_construct_impl (integral_constant<int, 0>, _Tp *__storage, const _Allocator &, _Args &&... __args ) -{ - new (__storage) _Tp (std::forward<_Args>(__args)...); +inline _LIBCPP_HIDE_FROM_ABI void +__user_alloc_construct_impl(integral_constant<int, 0>, _Tp* __storage, const _Allocator&, _Args&&... __args) { + new (__storage) _Tp(std::forward<_Args>(__args)...); } // FIXME: This should have a version which takes a non-const alloc. template <class _Tp, class _Allocator, class... _Args> -inline _LIBCPP_HIDE_FROM_ABI -void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) -{ - new (__storage) _Tp (allocator_arg_t(), __a, std::forward<_Args>(__args)...); +inline _LIBCPP_HIDE_FROM_ABI void +__user_alloc_construct_impl(integral_constant<int, 1>, _Tp* __storage, const _Allocator& __a, _Args&&... __args) { + new (__storage) _Tp(allocator_arg_t(), __a, std::forward<_Args>(__args)...); } // FIXME: This should have a version which takes a non-const alloc. template <class _Tp, class _Allocator, class... _Args> -inline _LIBCPP_HIDE_FROM_ABI -void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) -{ - new (__storage) _Tp (std::forward<_Args>(__args)..., __a); +inline _LIBCPP_HIDE_FROM_ABI void +__user_alloc_construct_impl(integral_constant<int, 2>, _Tp* __storage, const _Allocator& __a, _Args&&... __args) { + new (__storage) _Tp(std::forward<_Args>(__args)..., __a); } -template <class _Tp, class _Alloc, class ..._Args> -inline _LIBCPP_HIDE_FROM_ABI -void __lfts_user_alloc_construct( - _Tp * __store, const _Alloc & __a, _Args &&... __args) -{ - ::std::experimental::fundamentals_v1::__user_alloc_construct_impl( - typename __lfts_uses_alloc_ctor<_Tp, _Alloc, _Args...>::type() - , __store, __a, std::forward<_Args>(__args)... - ); +template <class _Tp, class _Alloc, class... _Args> +inline _LIBCPP_HIDE_FROM_ABI void __lfts_user_alloc_construct(_Tp* __store, const _Alloc& __a, _Args&&... __args) { + ::std::experimental::fundamentals_v1::__user_alloc_construct_impl( + typename __lfts_uses_alloc_ctor<_Tp, _Alloc, _Args...>::type(), __store, __a, std::forward<_Args>(__args)...); } _LIBCPP_END_NAMESPACE_LFTS diff --git a/libcxx/include/experimental/iterator b/libcxx/include/experimental/iterator index bca7d4c..5bb1dd1 100644 --- a/libcxx/include/experimental/iterator +++ b/libcxx/include/experimental/iterator @@ -71,48 +71,45 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS template <class _Delim, class _CharT = char, class _Traits = char_traits<_CharT>> class ostream_joiner { public: - - typedef _CharT char_type; - typedef _Traits traits_type; - typedef basic_ostream<char_type,traits_type> ostream_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - _LIBCPP_HIDE_FROM_ABI ostream_joiner(ostream_type& __os, _Delim&& __d) - : __output_iter_(std::addressof(__os)), __delim_(std::move(__d)), __first_(true) {} - - _LIBCPP_HIDE_FROM_ABI ostream_joiner(ostream_type& __os, const _Delim& __d) - : __output_iter_(std::addressof(__os)), __delim_(__d), __first_(true) {} - - - template<typename _Tp> - _LIBCPP_HIDE_FROM_ABI ostream_joiner& operator=(const _Tp& __v) - { - if (!__first_) - *__output_iter_ << __delim_; - __first_ = false; - *__output_iter_ << __v; - return *this; - } - - _LIBCPP_HIDE_FROM_ABI ostream_joiner& operator*() _NOEXCEPT { return *this; } - _LIBCPP_HIDE_FROM_ABI ostream_joiner& operator++() _NOEXCEPT { return *this; } - _LIBCPP_HIDE_FROM_ABI ostream_joiner& operator++(int) _NOEXCEPT { return *this; } + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_ostream<char_type, traits_type> ostream_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + _LIBCPP_HIDE_FROM_ABI ostream_joiner(ostream_type& __os, _Delim&& __d) + : __output_iter_(std::addressof(__os)), __delim_(std::move(__d)), __first_(true) {} + + _LIBCPP_HIDE_FROM_ABI ostream_joiner(ostream_type& __os, const _Delim& __d) + : __output_iter_(std::addressof(__os)), __delim_(__d), __first_(true) {} + + template <typename _Tp> + _LIBCPP_HIDE_FROM_ABI ostream_joiner& operator=(const _Tp& __v) { + if (!__first_) + *__output_iter_ << __delim_; + __first_ = false; + *__output_iter_ << __v; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI ostream_joiner& operator*() _NOEXCEPT { return *this; } + _LIBCPP_HIDE_FROM_ABI ostream_joiner& operator++() _NOEXCEPT { return *this; } + _LIBCPP_HIDE_FROM_ABI ostream_joiner& operator++(int) _NOEXCEPT { return *this; } private: - ostream_type* __output_iter_; - _Delim __delim_; - bool __first_; + ostream_type* __output_iter_; + _Delim __delim_; + bool __first_; }; - template <class _CharT, class _Traits, class _Delim> _LIBCPP_HIDE_FROM_ABI ostream_joiner<__decay_t<_Delim>, _CharT, _Traits> -make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim && __d) -{ return ostream_joiner<__decay_t<_Delim>, _CharT, _Traits>(__os, std::forward<_Delim>(__d)); } +make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim&& __d) { + return ostream_joiner<__decay_t<_Delim>, _CharT, _Traits>(__os, std::forward<_Delim>(__d)); +} _LIBCPP_END_NAMESPACE_LFTS diff --git a/libcxx/include/experimental/propagate_const b/libcxx/include/experimental/propagate_const index fd58f66..06d7ba4 100644 --- a/libcxx/include/experimental/propagate_const +++ b/libcxx/include/experimental/propagate_const @@ -146,69 +146,58 @@ template <class _Tp> class propagate_const; template <class _Up> -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR -const _Up& get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT; +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const _Up& get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT; template <class _Up> -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR -_Up& get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT; +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Up& get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT; template <class _Tp> -class propagate_const -{ +class propagate_const { public: typedef remove_reference_t<decltype(*std::declval<_Tp&>())> element_type; - static_assert(!is_array<_Tp>::value, - "Instantiation of propagate_const with an array type is ill-formed."); - static_assert(!is_reference<_Tp>::value, - "Instantiation of propagate_const with a reference type is ill-formed."); + static_assert(!is_array<_Tp>::value, "Instantiation of propagate_const with an array type is ill-formed."); + static_assert(!is_reference<_Tp>::value, "Instantiation of propagate_const with a reference type is ill-formed."); static_assert(!(is_pointer<_Tp>::value && is_function<__remove_pointer_t<_Tp> >::value), - "Instantiation of propagate_const with a function-pointer type is ill-formed."); + "Instantiation of propagate_const with a function-pointer type is ill-formed."); static_assert(!(is_pointer<_Tp>::value && is_same<__remove_cv_t<__remove_pointer_t<_Tp> >, void>::value), - "Instantiation of propagate_const with a pointer to (possibly cv-qualified) void is ill-formed."); + "Instantiation of propagate_const with a pointer to (possibly cv-qualified) void is ill-formed."); private: template <class _Up> - static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up* __u) - { + static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up* __u) { return __u; } template <class _Up> - static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up& __u) - { + static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up& __u) { return __get_pointer(__u.get()); } template <class _Up> - static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up* __u) - { + static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up* __u) { return __u; } template <class _Up> - static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up& __u) - { + static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up& __u) { return __get_pointer(__u.get()); } template <class _Up> - struct __is_propagate_const : false_type - { - }; + struct __is_propagate_const : false_type {}; template <class _Up> - struct __is_propagate_const<propagate_const<_Up>> : true_type - { - }; + struct __is_propagate_const<propagate_const<_Up>> : true_type {}; _Tp __t_; public: - - template <class _Up> friend _LIBCPP_CONSTEXPR const _Up& experimental::fundamentals_v2::get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT; - template <class _Up> friend _LIBCPP_CONSTEXPR _Up& experimental::fundamentals_v2::get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT; + template <class _Up> + friend _LIBCPP_CONSTEXPR const _Up& + experimental::fundamentals_v2::get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT; + template <class _Up> + friend _LIBCPP_CONSTEXPR _Up& experimental::fundamentals_v2::get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const() = default; @@ -216,100 +205,67 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(propagate_const&&) = default; - template <class _Up, enable_if_t<!is_convertible<_Up, _Tp>::value && - is_constructible<_Tp, _Up&&>::value,bool> = true> + template <class _Up, + enable_if_t<!is_convertible<_Up, _Tp>::value && is_constructible<_Tp, _Up&&>::value, bool> = true> explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu) - : __t_(std::move(experimental::get_underlying(__pu))) - { - } + : __t_(std::move(experimental::get_underlying(__pu))) {} - template <class _Up, enable_if_t<is_convertible<_Up&&, _Tp>::value && - is_constructible<_Tp, _Up&&>::value,bool> = false> + template <class _Up, + enable_if_t<is_convertible<_Up&&, _Tp>::value && is_constructible<_Tp, _Up&&>::value, bool> = false> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu) - : __t_(std::move(experimental::get_underlying(__pu))) - { - } + : __t_(std::move(experimental::get_underlying(__pu))) {} - template <class _Up, enable_if_t<!is_convertible<_Up&&, _Tp>::value && - is_constructible<_Tp, _Up&&>::value && - !__is_propagate_const<decay_t<_Up>>::value,bool> = true> - explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(_Up&& __u) - : __t_(std::forward<_Up>(__u)) - { - } + template <class _Up, + enable_if_t<!is_convertible<_Up&&, _Tp>::value && is_constructible<_Tp, _Up&&>::value && + !__is_propagate_const<decay_t<_Up>>::value, + bool> = true> + explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(_Up&& __u) : __t_(std::forward<_Up>(__u)) {} - template <class _Up, enable_if_t<is_convertible<_Up&&, _Tp>::value && - is_constructible<_Tp, _Up&&>::value && - !__is_propagate_const<decay_t<_Up>>::value,bool> = false> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(_Up&& __u) - : __t_(std::forward<_Up>(__u)) - { - } + template <class _Up, + enable_if_t<is_convertible<_Up&&, _Tp>::value && is_constructible<_Tp, _Up&&>::value && + !__is_propagate_const<decay_t<_Up>>::value, + bool> = false> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(_Up&& __u) : __t_(std::forward<_Up>(__u)) {} propagate_const& operator=(const propagate_const&) = delete; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const&&) = default; template <class _Up> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const<_Up>&& __pu) - { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const<_Up>&& __pu) { __t_ = std::move(experimental::get_underlying(__pu)); return *this; } template <class _Up, class _Vp = enable_if_t<!__is_propagate_const<decay_t<_Up>>::value>> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const& operator=(_Up&& __u) - { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const& operator=(_Up&& __u) { __t_ = std::forward<_Up>(__u); return *this; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* get() const - { - return __get_pointer(__t_); - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* get() const { return __get_pointer(__t_); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* get() - { - return __get_pointer(__t_); - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* get() { return __get_pointer(__t_); } - _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR operator bool() const - { - return get() != nullptr; - } + _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR operator bool() const { return get() != nullptr; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* operator->() const - { - return get(); - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* operator->() const { return get(); } - template <class _Dummy = _Tp, class _Up = enable_if_t<is_convertible< - const _Dummy, const element_type *>::value>> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator const element_type *() const { + template <class _Dummy = _Tp, class _Up = enable_if_t<is_convertible< const _Dummy, const element_type*>::value>> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator const element_type*() const { return get(); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type& operator*() const - { - return *get(); - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type& operator*() const { return *get(); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* operator->() - { - return get(); - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* operator->() { return get(); } - template <class _Dummy = _Tp, class _Up = enable_if_t< - is_convertible<_Dummy, element_type *>::value>> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator element_type *() { + template <class _Dummy = _Tp, class _Up = enable_if_t< is_convertible<_Dummy, element_type*>::value>> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator element_type*() { return get(); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type& operator*() - { - return *get(); - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type& operator*() { return *get(); } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR void swap(propagate_const& __pt) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) { @@ -318,184 +274,135 @@ public: } }; - template <class _Tp> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, nullptr_t) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, nullptr_t) { return experimental::get_underlying(__pt) == nullptr; } template <class _Tp> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator==(nullptr_t, const propagate_const<_Tp>& __pt) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator==(nullptr_t, const propagate_const<_Tp>& __pt) { return nullptr == experimental::get_underlying(__pt); } template <class _Tp> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, nullptr_t) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, nullptr_t) { return experimental::get_underlying(__pt) != nullptr; } template <class _Tp> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator!=(nullptr_t, const propagate_const<_Tp>& __pt) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, const propagate_const<_Tp>& __pt) { return nullptr != experimental::get_underlying(__pt); } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, - const propagate_const<_Up>& __pu) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool +operator==(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { return experimental::get_underlying(__pt) == experimental::get_underlying(__pu); } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, - const propagate_const<_Up>& __pu) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool +operator!=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { return experimental::get_underlying(__pt) != experimental::get_underlying(__pu); } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt, - const propagate_const<_Up>& __pu) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool +operator<(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { return experimental::get_underlying(__pt) < experimental::get_underlying(__pu); } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt, - const propagate_const<_Up>& __pu) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool +operator>(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { return experimental::get_underlying(__pt) > experimental::get_underlying(__pu); } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt, - const propagate_const<_Up>& __pu) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool +operator<=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { return experimental::get_underlying(__pt) <= experimental::get_underlying(__pu); } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt, - const propagate_const<_Up>& __pu) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool +operator>=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { return experimental::get_underlying(__pt) >= experimental::get_underlying(__pu); } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, const _Up& __u) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, const _Up& __u) { return experimental::get_underlying(__pt) == __u; } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, const _Up& __u) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, const _Up& __u) { return experimental::get_underlying(__pt) != __u; } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt, const _Up& __u) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt, const _Up& __u) { return experimental::get_underlying(__pt) < __u; } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt, const _Up& __u) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt, const _Up& __u) { return experimental::get_underlying(__pt) > __u; } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt, const _Up& __u) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt, const _Up& __u) { return experimental::get_underlying(__pt) <= __u; } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt, const _Up& __u) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt, const _Up& __u) { return experimental::get_underlying(__pt) >= __u; } - template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator==(const _Tp& __t, const propagate_const<_Up>& __pu) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator==(const _Tp& __t, const propagate_const<_Up>& __pu) { return __t == experimental::get_underlying(__pu); } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator!=(const _Tp& __t, const propagate_const<_Up>& __pu) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(const _Tp& __t, const propagate_const<_Up>& __pu) { return __t != experimental::get_underlying(__pu); } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator<(const _Tp& __t, const propagate_const<_Up>& __pu) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator<(const _Tp& __t, const propagate_const<_Up>& __pu) { return __t < experimental::get_underlying(__pu); } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator>(const _Tp& __t, const propagate_const<_Up>& __pu) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>(const _Tp& __t, const propagate_const<_Up>& __pu) { return __t > experimental::get_underlying(__pu); } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator<=(const _Tp& __t, const propagate_const<_Up>& __pu) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator<=(const _Tp& __t, const propagate_const<_Up>& __pu) { return __t <= experimental::get_underlying(__pu); } template <class _Tp, class _Up> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR bool operator>=(const _Tp& __t, const propagate_const<_Up>& __pu) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>=(const _Tp& __t, const propagate_const<_Up>& __pu) { return __t >= experimental::get_underlying(__pu); } template <class _Tp> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR void swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& __pc2) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) -{ +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR void swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& __pc2) + _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) { __pc1.swap(__pc2); } template <class _Tp> -_LIBCPP_CONSTEXPR const _Tp& get_underlying(const propagate_const<_Tp>& __pt) _NOEXCEPT -{ +_LIBCPP_CONSTEXPR const _Tp& get_underlying(const propagate_const<_Tp>& __pt) _NOEXCEPT { return __pt.__t_; } template <class _Tp> -_LIBCPP_CONSTEXPR _Tp& get_underlying(propagate_const<_Tp>& __pt) _NOEXCEPT -{ +_LIBCPP_CONSTEXPR _Tp& get_underlying(propagate_const<_Tp>& __pt) _NOEXCEPT { return __pt.__t_; } @@ -504,91 +411,77 @@ _LIBCPP_END_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp> -struct hash<experimental::propagate_const<_Tp>> -{ +struct hash<experimental::propagate_const<_Tp>> { typedef size_t result_type; typedef experimental::propagate_const<_Tp> argument_type; - _LIBCPP_HIDE_FROM_ABI size_t operator()(const experimental::propagate_const<_Tp>& __pc1) const - { + _LIBCPP_HIDE_FROM_ABI size_t operator()(const experimental::propagate_const<_Tp>& __pc1) const { return std::hash<_Tp>()(experimental::get_underlying(__pc1)); } }; template <class _Tp> -struct equal_to<experimental::propagate_const<_Tp>> -{ +struct equal_to<experimental::propagate_const<_Tp>> { typedef experimental::propagate_const<_Tp> first_argument_type; typedef experimental::propagate_const<_Tp> second_argument_type; - _LIBCPP_HIDE_FROM_ABI bool operator()(const experimental::propagate_const<_Tp>& __pc1, - const experimental::propagate_const<_Tp>& __pc2) const - { + _LIBCPP_HIDE_FROM_ABI bool + operator()(const experimental::propagate_const<_Tp>& __pc1, const experimental::propagate_const<_Tp>& __pc2) const { return std::equal_to<_Tp>()(experimental::get_underlying(__pc1), experimental::get_underlying(__pc2)); } }; template <class _Tp> -struct not_equal_to<experimental::propagate_const<_Tp>> -{ +struct not_equal_to<experimental::propagate_const<_Tp>> { typedef experimental::propagate_const<_Tp> first_argument_type; typedef experimental::propagate_const<_Tp> second_argument_type; - _LIBCPP_HIDE_FROM_ABI bool operator()(const experimental::propagate_const<_Tp>& __pc1, - const experimental::propagate_const<_Tp>& __pc2) const - { + _LIBCPP_HIDE_FROM_ABI bool + operator()(const experimental::propagate_const<_Tp>& __pc1, const experimental::propagate_const<_Tp>& __pc2) const { return std::not_equal_to<_Tp>()(experimental::get_underlying(__pc1), experimental::get_underlying(__pc2)); } }; template <class _Tp> -struct less<experimental::propagate_const<_Tp>> -{ +struct less<experimental::propagate_const<_Tp>> { typedef experimental::propagate_const<_Tp> first_argument_type; typedef experimental::propagate_const<_Tp> second_argument_type; - _LIBCPP_HIDE_FROM_ABI bool operator()(const experimental::propagate_const<_Tp>& __pc1, - const experimental::propagate_const<_Tp>& __pc2) const - { + _LIBCPP_HIDE_FROM_ABI bool + operator()(const experimental::propagate_const<_Tp>& __pc1, const experimental::propagate_const<_Tp>& __pc2) const { return std::less<_Tp>()(experimental::get_underlying(__pc1), experimental::get_underlying(__pc2)); } }; template <class _Tp> -struct greater<experimental::propagate_const<_Tp>> -{ +struct greater<experimental::propagate_const<_Tp>> { typedef experimental::propagate_const<_Tp> first_argument_type; typedef experimental::propagate_const<_Tp> second_argument_type; - _LIBCPP_HIDE_FROM_ABI bool operator()(const experimental::propagate_const<_Tp>& __pc1, - const experimental::propagate_const<_Tp>& __pc2) const - { + _LIBCPP_HIDE_FROM_ABI bool + operator()(const experimental::propagate_const<_Tp>& __pc1, const experimental::propagate_const<_Tp>& __pc2) const { return std::greater<_Tp>()(experimental::get_underlying(__pc1), experimental::get_underlying(__pc2)); } }; template <class _Tp> -struct less_equal<experimental::propagate_const<_Tp>> -{ +struct less_equal<experimental::propagate_const<_Tp>> { typedef experimental::propagate_const<_Tp> first_argument_type; typedef experimental::propagate_const<_Tp> second_argument_type; - _LIBCPP_HIDE_FROM_ABI bool operator()(const experimental::propagate_const<_Tp>& __pc1, - const experimental::propagate_const<_Tp>& __pc2) const - { + _LIBCPP_HIDE_FROM_ABI bool + operator()(const experimental::propagate_const<_Tp>& __pc1, const experimental::propagate_const<_Tp>& __pc2) const { return std::less_equal<_Tp>()(experimental::get_underlying(__pc1), experimental::get_underlying(__pc2)); } }; template <class _Tp> -struct greater_equal<experimental::propagate_const<_Tp>> -{ +struct greater_equal<experimental::propagate_const<_Tp>> { typedef experimental::propagate_const<_Tp> first_argument_type; typedef experimental::propagate_const<_Tp> second_argument_type; - _LIBCPP_HIDE_FROM_ABI bool operator()(const experimental::propagate_const<_Tp>& __pc1, - const experimental::propagate_const<_Tp>& __pc2) const - { + _LIBCPP_HIDE_FROM_ABI bool + operator()(const experimental::propagate_const<_Tp>& __pc1, const experimental::propagate_const<_Tp>& __pc2) const { return std::greater_equal<_Tp>()(experimental::get_underlying(__pc1), experimental::get_underlying(__pc2)); } }; diff --git a/libcxx/include/experimental/type_traits b/libcxx/include/experimental/type_traits index bebd86d..62f9574 100644 --- a/libcxx/include/experimental/type_traits +++ b/libcxx/include/experimental/type_traits @@ -73,12 +73,12 @@ inline namespace fundamentals_v1 { #if _LIBCPP_STD_VER >= 14 -#include <initializer_list> -#include <type_traits> +# include <initializer_list> +# include <type_traits> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_LFTS @@ -104,49 +104,48 @@ using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type; */ // 3.3.4, Detection idiom -template <class...> using void_t = void; +template <class...> +using void_t = void; struct nonesuch : private __nat { // make nonesuch "not an aggregate" - ~nonesuch() = delete; - nonesuch (nonesuch const&) = delete; + ~nonesuch() = delete; + nonesuch(nonesuch const&) = delete; void operator=(nonesuch const&) = delete; - }; +}; template <class _Default, class _AlwaysVoid, template <class...> class _Op, class... _Args> struct _DETECTOR { - using value_t = false_type; - using type = _Default; - }; + using value_t = false_type; + using type = _Default; +}; template <class _Default, template <class...> class _Op, class... _Args> struct _DETECTOR<_Default, void_t<_Op<_Args...>>, _Op, _Args...> { - using value_t = true_type; - using type = _Op<_Args...>; - }; - + using value_t = true_type; + using type = _Op<_Args...>; +}; -template <template<class...> class _Op, class... _Args> - using is_detected = typename _DETECTOR<nonesuch, void, _Op, _Args...>::value_t; -template <template<class...> class _Op, class... _Args> - using detected_t = typename _DETECTOR<nonesuch, void, _Op, _Args...>::type; -template <template<class...> class _Op, class... _Args> - _LIBCPP_CONSTEXPR bool is_detected_v = is_detected<_Op, _Args...>::value; +template <template <class...> class _Op, class... _Args> +using is_detected = typename _DETECTOR<nonesuch, void, _Op, _Args...>::value_t; +template <template <class...> class _Op, class... _Args> +using detected_t = typename _DETECTOR<nonesuch, void, _Op, _Args...>::type; +template <template <class...> class _Op, class... _Args> +_LIBCPP_CONSTEXPR bool is_detected_v = is_detected<_Op, _Args...>::value; -template <class _Default, template<class...> class _Op, class... _Args> - using detected_or = _DETECTOR<_Default, void, _Op, _Args...>; -template <class _Default, template<class...> class _Op, class... _Args> - using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type; - -template <class _Expected, template<class...> class _Op, class... _Args> - using is_detected_exact = is_same<_Expected, detected_t<_Op, _Args...>>; -template <class _Expected, template<class...> class _Op, class... _Args> - _LIBCPP_CONSTEXPR bool is_detected_exact_v = is_detected_exact<_Expected, _Op, _Args...>::value; +template <class _Default, template <class...> class _Op, class... _Args> +using detected_or = _DETECTOR<_Default, void, _Op, _Args...>; +template <class _Default, template <class...> class _Op, class... _Args> +using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type; -template <class _To, template<class...> class _Op, class... _Args> - using is_detected_convertible = is_convertible<detected_t<_Op, _Args...>, _To>; -template <class _To, template<class...> class _Op, class... _Args> - _LIBCPP_CONSTEXPR bool is_detected_convertible_v = is_detected_convertible<_To, _Op, _Args...>::value; +template <class _Expected, template <class...> class _Op, class... _Args> +using is_detected_exact = is_same<_Expected, detected_t<_Op, _Args...>>; +template <class _Expected, template <class...> class _Op, class... _Args> +_LIBCPP_CONSTEXPR bool is_detected_exact_v = is_detected_exact<_Expected, _Op, _Args...>::value; +template <class _To, template <class...> class _Op, class... _Args> +using is_detected_convertible = is_convertible<detected_t<_Op, _Args...>, _To>; +template <class _To, template <class...> class _Op, class... _Args> +_LIBCPP_CONSTEXPR bool is_detected_convertible_v = is_detected_convertible<_To, _Op, _Args...>::value; _LIBCPP_END_NAMESPACE_LFTS diff --git a/libcxx/include/experimental/utility b/libcxx/include/experimental/utility index 576b8be..c1bd936 100644 --- a/libcxx/include/experimental/utility +++ b/libcxx/include/experimental/utility @@ -40,7 +40,7 @@ inline namespace fundamentals_v1 { _LIBCPP_BEGIN_NAMESPACE_LFTS - struct _LIBCPP_TEMPLATE_VIS erased_type { }; +struct _LIBCPP_TEMPLATE_VIS erased_type {}; _LIBCPP_END_NAMESPACE_LFTS |