diff options
Diffstat (limited to 'include/gmock/gmock-generated-actions.h')
-rw-r--r-- | include/gmock/gmock-generated-actions.h | 71 |
1 files changed, 38 insertions, 33 deletions
diff --git a/include/gmock/gmock-generated-actions.h b/include/gmock/gmock-generated-actions.h index 64475910..ee26f385 100644 --- a/include/gmock/gmock-generated-actions.h +++ b/include/gmock/gmock-generated-actions.h @@ -908,31 +908,33 @@ class WithArgsAction { explicit WithArgsAction(const InnerAction& action) : action_(action) {} template <typename F> - operator Action<F>() const { + operator Action<F>() const { return MakeAction(new Impl<F>(action_)); } + + private: + template <typename F> + class Impl : public ActionInterface<F> { + public: typedef typename Function<F>::Result Result; typedef typename Function<F>::ArgumentTuple ArgumentTuple; - typedef typename SelectArgs<Result, ArgumentTuple, - k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type - InnerFunctionType; - class Impl : public ActionInterface<F> { - public: - explicit Impl(const InnerAction& action) : action_(action) {} + explicit Impl(const InnerAction& action) : action_(action) {} - virtual Result Perform(const ArgumentTuple& args) { - return action_.Perform(SelectArgs<Result, ArgumentTuple, k1, k2, k3, - k4, k5, k6, k7, k8, k9, k10>::Select(args)); - } - private: - Action<InnerFunctionType> action_; - }; + virtual Result Perform(const ArgumentTuple& args) { + return action_.Perform(SelectArgs<Result, ArgumentTuple, k1, k2, k3, k4, + k5, k6, k7, k8, k9, k10>::Select(args)); + } + + private: + typedef typename SelectArgs<Result, ArgumentTuple, + k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType; + + Action<InnerFunctionType> action_; + }; - return MakeAction(new Impl(action_)); - } - private: const InnerAction action_; }; + // Does two actions sequentially. Used for implementing the DoAll(a1, // a2, ...) action. template <typename Action1, typename Action2> @@ -945,28 +947,31 @@ class DoBothAction { // to be used in ANY function of compatible type. template <typename F> operator Action<F>() const { + return Action<F>(new Impl<F>(action1_, action2_)); + } + + private: + // Implements the DoAll(...) action for a particular function type F. + template <typename F> + class Impl : public ActionInterface<F> { + public: typedef typename Function<F>::Result Result; typedef typename Function<F>::ArgumentTuple ArgumentTuple; typedef typename Function<F>::MakeResultVoid VoidResult; - // Implements the DoAll(...) action for a particular function type F. - class Impl : public ActionInterface<F> { - public: - Impl(const Action<VoidResult>& action1, const Action<F>& action2) - : action1_(action1), action2_(action2) {} + Impl(const Action<VoidResult>& action1, const Action<F>& action2) + : action1_(action1), action2_(action2) {} - virtual Result Perform(const ArgumentTuple& args) { - action1_.Perform(args); - return action2_.Perform(args); - } - private: - const Action<VoidResult> action1_; - const Action<F> action2_; - }; + virtual Result Perform(const ArgumentTuple& args) { + action1_.Perform(args); + return action2_.Perform(args); + } + + private: + const Action<VoidResult> action1_; + const Action<F> action2_; + }; - return Action<F>(new Impl(action1_, action2_)); - } - private: Action1 action1_; Action2 action2_; }; |