struct Foo {
using tag_value_type = double;
double taroxd;
double kuerlulu;
};
struct Bar {
using tag_value_type = int;
int taroxd;
};
//////////
template
struct static_false {
using is_false = Ty;
constexpr bool operator()() {
return false;
}
};
template
struct static_true {
using is_true = Ty;
constexpr bool operator()() {
return true;
}
};
//////////
template
struct is_foo {
using value = static_false<>;
};
template<>
struct is_foo {
using value = static_true<>;
};
//////////
template
struct foo_traits_base {
using value_type = typename Ty::tag_value_type;
using has_kuerlulu = static_false<>;
};
template
struct foo_traits:public foo_traits_base {
};
template<>
struct foo_traits:foo_traits_base {
using has_kuerlulu = static_true<>;
};
//////////
template
typename Sb::is_false get_kuerlulu_if(Ty& obj) {
}
template
typename Sb::is_true get_kuerlulu_if(Ty& obj) {
cout << "We also have kuerlulu=" << obj.kuerlulu << "!" << endl;
}
template
void fun(Ty obj) {
if (is_foo::value()()) {
cout << "Foo!" << endl;
}
else {
cout << "Not foo!" << endl;
}
foo_traits::value_type v = obj.taroxd;
cout << v << endl;
get_kuerlulu_if::has_kuerlulu>(obj);
}
//////////
int main() {
Foo f = { 1.1,2.2 };
Bar b = { 3 };
fun(f);
fun(b);
}