Skip to content

Commit fc0c03f

Browse files
committed
refactor: add HasSetUpTearDown concept
1 parent a17ce9b commit fc0c03f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cucumber_cpp/library/Body.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define CUCUMBER_CPP_BODY_HPP
33

44
#include <any>
5+
#include <concepts>
56
#include <string>
67
#include <variant>
78
#include <vector>
@@ -15,7 +16,14 @@ namespace cucumber_cpp::library
1516
virtual void Execute(const std::variant<std::vector<std::string>, std::vector<std::any>>& args = {}) = 0;
1617
};
1718

18-
template<class T>
19+
template<typename T>
20+
concept HasSetUpTearDown =
21+
requires(T t) {
22+
{ t.SetUp() } -> std::convertible_to<void>;
23+
{ t.TearDown() } -> std::convertible_to<void>;
24+
};
25+
26+
template<HasSetUpTearDown T>
1927
struct SetUpTearDownWrapper
2028
{
2129
explicit SetUpTearDownWrapper(T& t)

0 commit comments

Comments
 (0)