Skip to content

[libc++][test] Close LWG3018 and add tests #93047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libcxx/docs/Status/Cxx20Issues.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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|"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,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**)
{
{
Expand Down Expand Up @@ -122,5 +143,6 @@ int main(int, char**)
}
#endif // TEST_STD_VER >= 11

test_function_type();
return 0;
}
Loading