Just to note, I cannot use the STL for this because one of the environments I'm targeting does not have a complete or accurate implementation of it.
I think I can use SFINAE to do this, but as much as it has been explained to me, I can't seem to wrap my head around it.
I have a type say:
struct Foo {
using test = char;
};
and
struct Bar {
};
I'd like to design a template type or template function such that it can detect the presence of the "test" member.
I know this is possible to do at compile time, again probably using SFINAE.
What I have tried:
I have a less elegant way to get what I want, but it's a lot of code to show here, and would require some explanation because it's pretty abstract.
The result I think would look something like this?
template<typename T> static inline constexpr bool check_test(typename T::test value) {
return true;
}
template<typename T> static inline constexpr bool check_test() {
return false;
}
That's not right, but i don't know how to make it right. I want to check if test is declared on the class/struct.