Skip to content

Commit

Permalink
Fixes for ci.
Browse files Browse the repository at this point in the history
Clang 3.6 requires the extra constructors in the custom_deleter.
  • Loading branch information
iwanders committed Nov 5, 2023
1 parent 23d5eac commit 1bc9821
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions include/pybind11/detail/smart_holder_type_casters.h
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,8 @@ struct smart_holder_type_caster_load {
extracted_deleter = std::move(custom_deleter_ptr->deleter);
} else {
// Not sure if anything needs to be done here. In general, if the del function is
// used a default destructor is used which should be accomodated by the type of the
// deleter used in the returned unique ptr.
// used a default destructor is used which should be accommodated by the type of
// the deleter used in the returned unique ptr.
}
}

Expand Down
4 changes: 3 additions & 1 deletion tests/test_class_sh_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ std::string pass_udcp(std::unique_ptr<atyp const, sddc> obj) { return "pass_udcp
struct custom_deleter
{
std::string delete_txt;
custom_deleter() {}
explicit custom_deleter(const std::string &delete_txt_) : delete_txt(delete_txt_) {}
void operator()(atyp* p) const
{
std::default_delete<atyp>()(p);
Expand All @@ -80,7 +82,7 @@ struct custom_deleter

std::unique_ptr<atyp, custom_deleter> rtrn_udmp_del() { return std::unique_ptr<atyp, custom_deleter>(new atyp{"rtrn_udmp_del"}, custom_deleter{"udmp_deleter"}); }
std::unique_ptr<atyp const, custom_deleter> rtrn_udcp_del() { return std::unique_ptr<atyp const, custom_deleter>(new atyp{"rtrn_udcp_del"}, custom_deleter{"udcp_deleter"}); }

std::string pass_udmp_del(std::unique_ptr<atyp, custom_deleter> obj) { return "pass_udmp_del:" + obj->mtxt + "," + obj.get_deleter().delete_txt; }
std::string pass_udcp_del(std::unique_ptr<atyp const, custom_deleter> obj) { return "pass_udcp_del:" + obj->mtxt + "," + obj.get_deleter().delete_txt; }

Expand Down
2 changes: 2 additions & 0 deletions tests/test_class_sh_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def test_load_with_mtxt(pass_f, mtxt, expected):
def test_load_with_rtrn_f(pass_f, rtrn_f, expected):
assert pass_f(rtrn_f()) == expected


@pytest.mark.parametrize(
("pass_f", "rtrn_f", "expected"),
[
Expand All @@ -74,6 +75,7 @@ def test_load_with_rtrn_f(pass_f, rtrn_f, expected):
def test_deleter_roundtrip(pass_f, rtrn_f, expected):
assert pass_f(rtrn_f()) == expected


@pytest.mark.parametrize(
("pass_f", "rtrn_f", "expected"),
[
Expand Down

0 comments on commit 1bc9821

Please sign in to comment.