MCPcopy Create free account
hub / github.com/OpenCppCoverage/OpenCppCoverage / AutoClose

Class AutoClose

TestHelper/AutoClose.hpp:23–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21 //-------------------------------------------------------------------------
22 template <typename Value, typename CloseAction>
23 class AutoClose
24 {
25 public:
26 //---------------------------------------------------------------------
27 AutoClose(Value value, Value invalidValue, CloseAction closeAction)
28 : value_{ value }
29 , closeAction_{ closeAction }
30 {
31 if (value_ == invalidValue)
32 throw std::runtime_error("The value is invalid");
33 }
34
35 //---------------------------------------------------------------------
36 ~AutoClose()
37 {
38 closeAction_(value_);
39 }
40
41 //---------------------------------------------------------------------
42 Value operator*()
43 {
44 return value_;
45 }
46
47 private:
48 Value value_;
49 CloseAction closeAction_;
50 };
51
52 //-------------------------------------------------------------------------
53 template <typename Value, typename InvalidValue, typename CloseAction>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected