Skip to content

Commit

Permalink
[libc++] Eliminate the __function_like helper.
Browse files Browse the repository at this point in the history
As prefigured in the comments on D115315.
This gives us one unified style for all niebloids,
and also simplifies the modulemap.

Differential Revision: https://reviews.llvm.org/D116570
  • Loading branch information
Arthur O'Dwyer committed Jan 20, 2022
1 parent 94e69fb commit 63a991d
Show file tree
Hide file tree
Showing 14 changed files with 230 additions and 286 deletions.
1 change: 0 additions & 1 deletion libcxx/include/CMakeLists.txt
Expand Up @@ -182,7 +182,6 @@ set(files
__format/formatter_integral.h
__format/formatter_string.h
__format/parser_std_format_spec.h
__function_like.h
__functional/binary_function.h
__functional/binary_negate.h
__functional/bind.h
Expand Down
51 changes: 0 additions & 51 deletions libcxx/include/__function_like.h

This file was deleted.

7 changes: 2 additions & 5 deletions libcxx/include/__iterator/advance.h
Expand Up @@ -12,7 +12,6 @@

#include <__config>
#include <__debug>
#include <__function_like.h>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
#include <__iterator/iterator_traits.h>
Expand Down Expand Up @@ -72,7 +71,7 @@ void advance(_InputIter& __i, _Distance __orig_n) {
namespace ranges {
namespace __advance {

struct __fn final : private __function_like {
struct __fn {
private:
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI
Expand All @@ -99,8 +98,6 @@ struct __fn final : private __function_like {
}

public:
constexpr explicit __fn(__tag __x) noexcept : __function_like(__x) {}

// Preconditions: If `I` does not model `bidirectional_iterator`, `n` is not negative.
template <input_or_output_iterator _Ip>
_LIBCPP_HIDE_FROM_ABI
Expand Down Expand Up @@ -191,7 +188,7 @@ struct __fn final : private __function_like {
} // namespace __advance

inline namespace __cpo {
inline constexpr auto advance = __advance::__fn(__function_like::__tag());
inline constexpr auto advance = __advance::__fn{};
} // namespace __cpo
} // namespace ranges

Expand Down
8 changes: 2 additions & 6 deletions libcxx/include/__iterator/next.h
Expand Up @@ -12,7 +12,6 @@

#include <__config>
#include <__debug>
#include <__function_like.h>
#include <__iterator/advance.h>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
Expand Down Expand Up @@ -43,10 +42,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
namespace ranges {
namespace __next {

struct __fn final : private __function_like {
_LIBCPP_HIDE_FROM_ABI
constexpr explicit __fn(__tag __x) noexcept : __function_like(__x) {}

struct __fn {
template <input_or_output_iterator _Ip>
_LIBCPP_HIDE_FROM_ABI
constexpr _Ip operator()(_Ip __x) const {
Expand Down Expand Up @@ -79,7 +75,7 @@ struct __fn final : private __function_like {
} // namespace __next

inline namespace __cpo {
inline constexpr auto next = __next::__fn(__function_like::__tag());
inline constexpr auto next = __next::__fn{};
} // namespace __cpo
} // namespace ranges

Expand Down
8 changes: 2 additions & 6 deletions libcxx/include/__iterator/prev.h
Expand Up @@ -12,7 +12,6 @@

#include <__config>
#include <__debug>
#include <__function_like.h>
#include <__iterator/advance.h>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
Expand Down Expand Up @@ -42,10 +41,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
namespace ranges {
namespace __prev {

struct __fn final : private __function_like {
_LIBCPP_HIDE_FROM_ABI
constexpr explicit __fn(__tag __x) noexcept : __function_like(__x) {}

struct __fn {
template <bidirectional_iterator _Ip>
_LIBCPP_HIDE_FROM_ABI
constexpr _Ip operator()(_Ip __x) const {
Expand All @@ -71,7 +67,7 @@ struct __fn final : private __function_like {
} // namespace __prev

inline namespace __cpo {
inline constexpr auto prev = __prev::__fn(__function_like::__tag());
inline constexpr auto prev = __prev::__fn{};
} // namespace __cpo
} // namespace ranges

Expand Down
26 changes: 9 additions & 17 deletions libcxx/include/__memory/ranges_construct_at.h
Expand Up @@ -12,7 +12,6 @@

#include <__concepts/destructible.h>
#include <__config>
#include <__function_like.h>
#include <__iterator/incrementable_traits.h>
#include <__iterator/readable_traits.h>
#include <__memory/concepts.h>
Expand All @@ -37,9 +36,7 @@ namespace ranges {

namespace __construct_at {

struct __fn final : private __function_like {
_LIBCPP_HIDE_FROM_ABI constexpr explicit __fn(__tag __x) noexcept : __function_like(__x) {}

struct __fn {
template<class _Tp, class... _Args, class = decltype(
::new (declval<void*>()) _Tp(declval<_Args>()...)
)>
Expand All @@ -52,16 +49,14 @@ struct __fn final : private __function_like {
} // namespace __construct_at

inline namespace __cpo {
inline constexpr auto construct_at = __construct_at::__fn(__function_like::__tag());
inline constexpr auto construct_at = __construct_at::__fn{};
} // namespace __cpo

// destroy_at

namespace __destroy_at {

struct __fn final : private __function_like {
_LIBCPP_HIDE_FROM_ABI constexpr explicit __fn(__tag __x) noexcept : __function_like(__x) {}

struct __fn {
template <destructible _Tp>
_LIBCPP_HIDE_FROM_ABI
constexpr void operator()(_Tp* __location) const noexcept {
Expand All @@ -72,16 +67,14 @@ struct __fn final : private __function_like {
} // namespace __destroy_at

inline namespace __cpo {
inline constexpr auto destroy_at = __destroy_at::__fn(__function_like::__tag());
inline constexpr auto destroy_at = __destroy_at::__fn{};
} // namespace __cpo

// destroy

namespace __destroy {

struct __fn final : private __function_like {
_LIBCPP_HIDE_FROM_ABI constexpr explicit __fn(__tag __x) noexcept : __function_like(__x) {}

struct __fn {
template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel>
requires destructible<iter_value_t<_InputIterator>>
_LIBCPP_HIDE_FROM_ABI
Expand All @@ -100,16 +93,14 @@ struct __fn final : private __function_like {
} // namespace __destroy

inline namespace __cpo {
inline constexpr auto destroy = __destroy::__fn(__function_like::__tag());
inline constexpr auto destroy = __destroy::__fn{};
} // namespace __cpo

// destroy_n

namespace __destroy_n {

struct __fn final : private __function_like {
_LIBCPP_HIDE_FROM_ABI constexpr explicit __fn(__tag __x) noexcept : __function_like(__x) {}

struct __fn {
template <__nothrow_input_iterator _InputIterator>
requires destructible<iter_value_t<_InputIterator>>
_LIBCPP_HIDE_FROM_ABI
Expand All @@ -121,10 +112,11 @@ struct __fn final : private __function_like {
} // namespace __destroy_n

inline namespace __cpo {
inline constexpr auto destroy_n = __destroy_n::__fn(__function_like::__tag());
inline constexpr auto destroy_n = __destroy_n::__fn{};
} // namespace __cpo

} // namespace ranges

#endif // !defined(_LIBCPP_HAS_NO_RANGES)

_LIBCPP_END_NAMESPACE_STD
Expand Down

0 comments on commit 63a991d

Please sign in to comment.