[libcxx-commits] [libcxx] 9595eb1 - [libc++][test] Close LWG3018 and add tests (#93047)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed May 29 10:46:42 PDT 2024
Author: Hui
Date: 2024-05-29T18:46:39+01:00
New Revision: 9595eb10ae9a5661a596dff19bf39365140548e3
URL: https://github.com/llvm/llvm-project/commit/9595eb10ae9a5661a596dff19bf39365140548e3
DIFF: https://github.com/llvm/llvm-project/commit/9595eb10ae9a5661a596dff19bf39365140548e3.diff
LOG: [libc++][test] Close LWG3018 and add tests (#93047)
Added:
Modified:
libcxx/docs/Status/Cxx20Issues.csv
libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/docs/Status/Cxx20Issues.csv b/libcxx/docs/Status/Cxx20Issues.csv
index 54517ab002b86..e748ff6ad749b 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -191,7 +191,7 @@
"","","","","",""
"`1203 <https://wg21.link/LWG1203>`__","More useful rvalue stream insertion","Prague","|Complete|","12.0"
"`2859 <https://wg21.link/LWG2859>`__","Definition of *reachable* in [ptr.launder] misses pointer arithmetic from pointer-interconvertible object","Prague","",""
-"`3018 <https://wg21.link/LWG3018>`__","``shared_ptr``\ of function type","Prague","",""
+"`3018 <https://wg21.link/LWG3018>`__","``shared_ptr``\ of function type","Prague","|Nothing To Do|",""
"`3050 <https://wg21.link/LWG3050>`__","Conversion specification problem in ``chrono::duration``\ constructor","Prague","|Complete|","19.0","|chrono|"
"`3141 <https://wg21.link/LWG3141>`__","``CopyConstructible``\ doesn't preserve source values","Prague","|Nothing to do|",""
"`3150 <https://wg21.link/LWG3150>`__","``UniformRandomBitGenerator``\ should validate ``min``\ and ``max``\ ","Prague","|Complete|","13.0","|ranges|"
diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
index 9c1e9b72be573..562acf56d96fe 100644
--- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
+++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
@@ -48,6 +48,27 @@ static_assert(!std::is_constructible<std::shared_ptr<int[5]>, int*, bad_deleter>
static_assert(!std::is_constructible<std::shared_ptr<int[5]>, int(*)[5], test_deleter<int> >::value, "");
#endif
+int f() { return 5; }
+
+// https://cplusplus.github.io/LWG/issue3018
+// LWG 3018. shared_ptr of function type
+struct function_pointer_deleter {
+ function_pointer_deleter(bool& deleter_called) : deleter_called_(deleter_called) {}
+
+ void operator()(int (*)()) const { deleter_called_ = true; }
+
+ bool& deleter_called_;
+};
+
+void test_function_type() {
+ bool deleter_called = false;
+ {
+ std::shared_ptr<int()> p(&f, function_pointer_deleter(deleter_called));
+ assert((*p)() == 5);
+ }
+ assert(deleter_called);
+}
+
int main(int, char**)
{
{
@@ -94,5 +115,6 @@ int main(int, char**)
}
#endif // TEST_STD_VER >= 11
+ test_function_type();
return 0;
}
More information about the libcxx-commits
mailing list