[libc++][NFC] Add documentation for _Or and _And
authorLouis Dionne <ldionne.2@gmail.com>
Fri, 21 Oct 2022 16:25:29 +0000 (12:25 -0400)
committerLouis Dionne <ldionne.2@gmail.com>
Fri, 21 Oct 2022 16:25:29 +0000 (12:25 -0400)
libcxx/include/__type_traits/conjunction.h
libcxx/include/__type_traits/disjunction.h

index 9715854..2802d28 100644 (file)
@@ -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));
 
index 465411a..125f168 100644 (file)
@@ -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...>;