Make MOCK_SIGNATURE macro shorter

Put most of it into a template-alias as this may turn up in error messages
This commit is contained in:
Alexander Grund 2022-01-25 18:46:18 +01:00
parent c00b03de44
commit 0c20ca1ce9
No known key found for this signature in database
GPG key ID: AA48A0760367A42B

View file

@ -54,21 +54,22 @@ namespace mock { namespace detail {
struct signature<Sig(C::*)> : signature<typename strip_function_qualifiers<Sig>::type>
{};
template<typename M>
using signature_t = typename signature<std::remove_cv_t<std::remove_reference_t<M>>>::type;
template<typename T>
struct base
{
typedef T base_type;
};
// if an error is generated by the line below it means
// the method is ambiguous : specify its signature to
// disambiguate
// if an error is generated by the line below it means the method is ambiguous:
// specify its signature to disambiguate
template<typename T>
T& ambiguous_method_requires_to_specify_signature(const T&);
}} // namespace mock::detail
#define MOCK_SIGNATURE(M) \
mock::detail::signature<std::remove_cv_t<std::remove_reference_t<decltype( \
mock::detail::ambiguous_method_requires_to_specify_signature(&base_type::M))>>>::type
#define MOCK_SIGNATURE(M) \
mock::detail::signature_t<decltype(mock::detail::ambiguous_method_requires_to_specify_signature(&base_type::M))>
#endif // MOCK_SIGNATURE_HPP_INCLUDED