Skip to content

Commit

Permalink
[libc++][NFC] Add documentation for _Or and _And
Browse files Browse the repository at this point in the history
  • Loading branch information
ldionne committed Oct 21, 2022
1 parent 07d8fe9 commit fc41512
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libcxx/include/__type_traits/conjunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ __expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);
template <class...>
false_type __and_helper(...);

// _And always performs lazy evaluation of its arguments.
//
// However, `_And<_Pred...>` itself will evaluate its result immediately (without having to
// be instantiated) since it is an alias, unlike `conjunction<_Pred...>`, which is a struct.
// If you want to defer the evaluation of `_And<_Pred...>` itself, use `_Lazy<_And, _Pred...>`.
template <class... _Pred>
using _And _LIBCPP_NODEBUG = decltype(__and_helper<_Pred...>(0));

Expand Down
6 changes: 6 additions & 0 deletions libcxx/include/__type_traits/disjunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ struct _OrImpl<false> {
using _Result = _Res;
};

// _Or always performs lazy evaluation of its arguments.
//
// However, `_Or<_Pred...>` itself will evaluate its result immediately (without having to
// be instantiated) since it is an alias, unlike `disjunction<_Pred...>`, which is a struct.
// If you want to defer the evaluation of `_Or<_Pred...>` itself, use `_Lazy<_Or, _Pred...>`
// or `disjunction<_Pred...>` directly.
template <class... _Args>
using _Or _LIBCPP_NODEBUG = typename _OrImpl<sizeof...(_Args) != 0>::template _Result<false_type, _Args...>;

Expand Down

1 comment on commit fc41512

@EricWF
Copy link
Member

@EricWF EricWF commented on fc41512 Oct 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seams super strang these aren't consistent.

Please sign in to comment.