MCPcopy Create free account
hub / github.com/arun11299/cpp-subprocess / preexec_func

Class preexec_func

cpp-subprocess/subprocess.hpp:1014–1041  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1012// aiming for. If you know, then please do let me know.
1013
1014class preexec_func
1015{
1016public:
1017 preexec_func() {}
1018
1019 template <typename Func>
1020 explicit preexec_func(Func f): holder_(new FuncHolder<Func>(std::move(f)))
1021 {}
1022
1023 void operator()() {
1024 (*holder_)();
1025 }
1026
1027private:
1028 struct HolderBase {
1029 virtual void operator()() const = 0;
1030 virtual ~HolderBase(){};
1031 };
1032 template <typename T>
1033 struct FuncHolder: HolderBase {
1034 FuncHolder(T func): func_(std::move(func)) {}
1035 void operator()() const override { func_(); }
1036 // The function pointer/reference
1037 T func_;
1038 };
1039
1040 std::unique_ptr<HolderBase> holder_ = nullptr;
1041};
1042
1043// ~~~~ End Popen Args ~~~~
1044

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected