From fc41512fd3e36fe26e9ff3aa53493c5dcf75b506 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Fri, 21 Oct 2022 12:25:29 -0400 Subject: [PATCH] [libc++][NFC] Add documentation for _Or and _And --- libcxx/include/__type_traits/conjunction.h | 5 +++++ libcxx/include/__type_traits/disjunction.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/libcxx/include/__type_traits/conjunction.h b/libcxx/include/__type_traits/conjunction.h index 9715854..2802d28 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 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 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 465411a..125f168 100644 --- a/libcxx/include/__type_traits/disjunction.h +++ b/libcxx/include/__type_traits/disjunction.h @@ -34,6 +34,12 @@ struct _OrImpl { 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 using _Or _LIBCPP_NODEBUG = typename _OrImpl::template _Result; -- 2.7.4