Here is the original post again with comments to aid in understanding:
struct Foo
{
// Our own mocked method that the templated call will end up calling.
MOCK_METHOD3(GetNextValueStdString, void(const std::string& name, std::string& value, const unsigned int streamIndex));
// If we see any calls with these two parameter list types throw and error as its unexpected in the unit under test.
template< typename ValueType >
void GetNextValue( const std::string& name, ValueType& value, const unsigned int streamIndex )
{
throw "Unexpected call.";
}
template< typename ValueType >
void GetNextValue( const std::string& name, ValueType& value )
{
throw "Unexpected call.";
}
// These are the only two templated calls expected, notice the difference in the method parameter list. Anything outside
// of these two flavors is considerd an error.
template<>
void GetNextValue< std::string >( const std::string& name, std::string& value, const unsigned int streamIndex )
{
GetNextValueStdString( name, value, streamIndex );
}
template<>
void GetNextValue< std::string >( const std::string& name, std::string& value )
{
GetNextValue< std::string >( name, value, 0 );
}
};