Skip to content

Commit 0a0ea92

Browse files
authored
fix: Add a virtual destructor to DependencyProvider (#50)
* fix: Add a virtual destructor to `DependencyProvider` Signed-off-by: Julien Jerphanion <git@jjerphan.xyz> * lint: Format file Signed-off-by: Julien Jerphanion <git@jjerphan.xyz> --------- Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
1 parent d90bc3a commit 0a0ea92

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

cpp/include/resolvo_dependency_provider.h

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ using cbindgen_private::VersionSetId;
1818
* An interface that implements ecosystem specific logic.
1919
*/
2020
struct DependencyProvider {
21+
virtual ~DependencyProvider() = default;
22+
2123
/**
2224
* Returns a user-friendly string representation of the specified solvable.
2325
*

cpp/tests/solve.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ SCENARIO("Solve") {
167167
/// Construct a database with packages a, b, and c.
168168
PackageDatabase db;
169169

170+
// Check that PackageDatabase correctly implements the DependencyProvider interface
171+
static_assert(std::has_virtual_destructor_v<PackageDatabase>);
172+
static_assert(std::is_polymorphic_v<PackageDatabase>);
173+
static_assert(std::is_base_of_v<resolvo::DependencyProvider, PackageDatabase>);
174+
170175
auto a_1 = db.alloc_candidate("a", 1, {{db.alloc_requirement("b", 1, 4)}, {}});
171176
auto a_2 = db.alloc_candidate("a", 2, {{db.alloc_requirement("b", 1, 4)}, {}});
172177
auto a_3 = db.alloc_candidate("a", 3, {{db.alloc_requirement("b", 4, 7)}, {}});

0 commit comments

Comments
 (0)