Files
clang-uml/tests/t20008/t20008.cc
2022-11-27 15:23:32 +01:00

43 lines
668 B
C++

#include <type_traits>
#include <string>
namespace clanguml {
namespace t20008
{
template <typename T> struct A {
void a1(T arg) { }
void a2(T arg) { }
void a3(T arg) { }
};
template <typename T> struct B {
A<T> a;
void b(T arg) {
if constexpr (std::is_integral_v<T>) {
a.a1(arg);
}
else if constexpr(std::is_pointer_v<T>) {
a.a2(arg);
}
else {
a.a3(arg);
}
}
};
void tmain() {
using namespace std::string_literals;
B<int> bint;
B<const char*> bcharp;
B<std::string> bstring;
bint.b(1);
bcharp.b("1");
bstring.b("1"s);
}
}
}