I was trying to do a motivating example for SFINAE, when I noticed that you don't need that for the following:
#include <iostream>
using namespace std;
template<typename T>
struct Foo
{
void add(int count, const T& val) // add "count" number of val's
{
cout << "count, val" << endl;
}
template<typename It>
void add(It beg, It end) // add items [beg,end)
{
cout << "beg, end" << endl;
}
};
int main()
{
int a=1;
int xx[] = {1,2,3};
Foo<int> foo;
foo.add(xx, xx+3);
foo.add(2, a);
}
This compiles, runs, and prints:
beg, end
count, val
I do not understand why the second call to add is not ambiguous.