P
Peng Yu
Hi,
I have the following code (some part is not working). I would like A
behave differently depending on whether the template argument is from
the namespace space2 or not. Is it possible to do it?
Thanks,
Peng
#include <iostream>
namespace space2 {
class B { };
}
namespace space1 {
template <typename T>
struct A {
void doit() {
std::cout << "A<T>" << std::endl;
}
};
// I want this match any class from namespace space2
template <typename T>
struct A<typename space2::T> {
void doit() {
std::cout << "namespace space2" << std::endl;
}
};
}
int main() {
space1::A<double>().doit();
space1::A<space2::B>().doit();
}
I have the following code (some part is not working). I would like A
behave differently depending on whether the template argument is from
the namespace space2 or not. Is it possible to do it?
Thanks,
Peng
#include <iostream>
namespace space2 {
class B { };
}
namespace space1 {
template <typename T>
struct A {
void doit() {
std::cout << "A<T>" << std::endl;
}
};
// I want this match any class from namespace space2
template <typename T>
struct A<typename space2::T> {
void doit() {
std::cout << "namespace space2" << std::endl;
}
};
}
int main() {
space1::A<double>().doit();
space1::A<space2::B>().doit();
}