-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for std::function in MockFunction (#2277)
- Loading branch information
1 parent
c27aceb
commit 334d349
Showing
4 changed files
with
146 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#ifndef THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_SIGNATUREOF_H_ | ||
#define THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_SIGNATUREOF_H_ | ||
|
||
#include <functional> | ||
|
||
namespace testing { | ||
namespace internal { | ||
|
||
/* | ||
The SignatureOf<F> struct is a meta-function returning function signature | ||
corresponding to the provided F argument. | ||
It makes use of MockFunction easier by allowing it to accept more F arguments | ||
than just function signatures. | ||
Specializations provided here cover only a signature type itself and | ||
std::function. However, if need be it can be easily extended to cover also other | ||
types (like for example boost::function). | ||
*/ | ||
|
||
template <typename F> | ||
struct SignatureOf; | ||
|
||
template <typename R, typename... Args> | ||
struct SignatureOf<R(Args...)> { | ||
using type = R(Args...); | ||
}; | ||
|
||
template <typename F> | ||
struct SignatureOf<std::function<F>> : SignatureOf<F> {}; | ||
|
||
template <typename F> | ||
using SignatureOfT = typename SignatureOf<F>::type; | ||
|
||
} // namespace internal | ||
} // namespace testing | ||
|
||
#endif // THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_SIGNATUREOF_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters