On 18 February 2013 09:38, Partha Biswas <
pbisw...@gmail.com> wrote:
> Hi,
>
> Kindly consider the following piece of code :
>
> class A
> {
> public:
> virtual std::map<int, int>& getthedata() = 0;
> };
>
> class AMock : public A
> {
> public:
> MOCK_METHOD0(getthedata, std::map<int,int>&());
> };
>
> This gives a compilation error
> error: macro "MOCK_METHOD0" passed 3 arguments, but takes just 2
>
> I realized that if i mock as shown below the compilation goes through:
>
> class AMock : public A
> {
> public:
> typedef std::map<int, map> mapdata;
> MOCK_METHOD0(getthedata, mapdata&());
> };
>
> My question : Are there any other way to solve this?
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Google C++ Mocking Framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
googlemock+...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>
There are only two methods worth noting to ignore the commas in the
template type in a macro. One is as you have listed (using a typedef)
and the other being that you enclose the template type inside
parentheses, although for this method to work in most situations then
the macro had to have been written with this in mind as the
parentheses are not removed when the macro is expanded.
--Liam