[libcxx-commits] [libcxx] [libc++][functional] Implement `not_fn<NTTP>` (PR #86133)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Nov 28 12:28:17 PST 2024
================
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <functional>
+
+// Type of `std::not_fn<NTTP>()` is always empty.
+
+#include <functional>
+#include <type_traits>
+
+struct NonEmptyFunctionObject {
+ bool val = true;
+ bool operator()() const; // not defined
+};
+
+void test() {
+ using ResultWithEmptyFuncObject = decltype(std::not_fn<std::false_type{}>());
+ static_assert(std::is_empty_v<ResultWithEmptyFuncObject>);
+
+ using ResultWithNotEmptyFuncObject = decltype(std::not_fn<NonEmptyFunctionObject{}>());
+ static_assert(std::is_empty_v<ResultWithNotEmptyFuncObject>);
----------------
ldionne wrote:
This doesn't need to be in a function, it can be at file scope!
https://github.com/llvm/llvm-project/pull/86133
More information about the libcxx-commits
mailing list