C
cpp_weenie
Hello group,
Should the program below be valid? Or should it generate a compilation
error? Any references to the Standard would be appreciated...
Thanks!
#include <iostream>
using namespace std;
struct foo
{
int a;
int b;
};
template<typename T1, typename T2, typename T3>
bool before(T2 T1::*mem1, T3 T1::*mem2)
{
return mem1 < mem2;
}
int main()
{
if (before(&foo::a, &foo::b))
cout << "foo::a comes before foo::b in memory" << endl;
else
cout << "foo::b comes before foo::a in memory" << endl;
return 0;
}
Should the program below be valid? Or should it generate a compilation
error? Any references to the Standard would be appreciated...
Thanks!
#include <iostream>
using namespace std;
struct foo
{
int a;
int b;
};
template<typename T1, typename T2, typename T3>
bool before(T2 T1::*mem1, T3 T1::*mem2)
{
return mem1 < mem2;
}
int main()
{
if (before(&foo::a, &foo::b))
cout << "foo::a comes before foo::b in memory" << endl;
else
cout << "foo::b comes before foo::a in memory" << endl;
return 0;
}