[libcxx-commits] [libcxx] fc41512 - [libc++][NFC] Add documentation for _Or and _And

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Oct 21 09:25:39 PDT 2022


Author: Louis Dionne
Date: 2022-10-21T12:25:29-04:00
New Revision: fc41512fd3e36fe26e9ff3aa53493c5dcf75b506

URL: https://github.com/llvm/llvm-project/commit/fc41512fd3e36fe26e9ff3aa53493c5dcf75b506
DIFF: https://github.com/llvm/llvm-project/commit/fc41512fd3e36fe26e9ff3aa53493c5dcf75b506.diff

LOG: [libc++][NFC] Add documentation for _Or and _And

Added: 
    

Modified: 
    libcxx/include/__type_traits/conjunction.h
    libcxx/include/__type_traits/disjunction.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__type_traits/conjunction.h b/libcxx/include/__type_traits/conjunction.h
index 9715854fa0af1..2802d284527b0 100644
--- a/libcxx/include/__type_traits/conjunction.h
+++ b/libcxx/include/__type_traits/conjunction.h
@@ -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));
 

diff  --git a/libcxx/include/__type_traits/disjunction.h b/libcxx/include/__type_traits/disjunction.h
index 465411acb316e..125f168acc3a5 100644
--- a/libcxx/include/__type_traits/disjunction.h
+++ b/libcxx/include/__type_traits/disjunction.h
@@ -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...>;
 


        


More information about the libcxx-commits mailing list