| 1012 | // aiming for. If you know, then please do let me know. |
| 1013 | |
| 1014 | class preexec_func |
| 1015 | { |
| 1016 | public: |
| 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 | |
| 1027 | private: |
| 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 |
nothing calls this directly
no outgoing calls
no test coverage detected