Library: attempt to get more explicit type diagnostics
...including the various reference and pointer adornments; typeid() unfortunately strips those, so we'll have to add them manually
This commit is contained in:
parent
60301f7523
commit
d73b0b05b2
1 changed files with 63 additions and 1 deletions
|
|
@ -59,11 +59,64 @@ namespace test{
|
||||||
struct Space { };
|
struct Space { };
|
||||||
using Join = ulong;
|
using Join = ulong;
|
||||||
|
|
||||||
|
template<typename X>
|
||||||
|
struct Bugg
|
||||||
|
{
|
||||||
|
static_assert (not sizeof(X), "guggi");
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename X>
|
||||||
|
struct TypeDiagnostics
|
||||||
|
{
|
||||||
|
using Type = X;
|
||||||
|
static constexpr auto postfix = "";
|
||||||
|
};
|
||||||
|
template<typename X>
|
||||||
|
struct TypeDiagnostics<X&>
|
||||||
|
{
|
||||||
|
using Type = X;
|
||||||
|
static constexpr auto postfix = "&";
|
||||||
|
};
|
||||||
|
template<typename X>
|
||||||
|
struct TypeDiagnostics<X&&>
|
||||||
|
{
|
||||||
|
using Type = X;
|
||||||
|
static constexpr auto postfix = " &&";
|
||||||
|
};
|
||||||
|
template<typename X>
|
||||||
|
struct TypeDiagnostics<X const&>
|
||||||
|
{
|
||||||
|
using Type = X;
|
||||||
|
static constexpr auto postfix = " const&";
|
||||||
|
};
|
||||||
|
template<typename X>
|
||||||
|
struct TypeDiagnostics<X const&&>
|
||||||
|
{
|
||||||
|
using Type = X;
|
||||||
|
static constexpr auto postfix = " const &&";
|
||||||
|
};
|
||||||
|
template<typename X>
|
||||||
|
struct TypeDiagnostics<X *>
|
||||||
|
{
|
||||||
|
using Type = X;
|
||||||
|
static constexpr auto postfix = " *";
|
||||||
|
};
|
||||||
|
template<typename X>
|
||||||
|
struct TypeDiagnostics<X * const>
|
||||||
|
{
|
||||||
|
using Type = X;
|
||||||
|
static constexpr auto postfix = " * const";
|
||||||
|
};
|
||||||
|
|
||||||
template<typename X>
|
template<typename X>
|
||||||
inline string
|
inline string
|
||||||
showType()
|
showType()
|
||||||
{
|
{
|
||||||
return humanReadableTypeID (typeid(X).name());
|
using Case = TypeDiagnostics<X>;
|
||||||
|
using Type = typename Case::Type;
|
||||||
|
|
||||||
|
return humanReadableTypeID (typeid(Type).name())
|
||||||
|
+ Case::postfix;
|
||||||
}
|
}
|
||||||
|
|
||||||
}//(end)fixture
|
}//(end)fixture
|
||||||
|
|
@ -166,6 +219,15 @@ namespace test{
|
||||||
cout << showType<TypeBinding<Join * const>::value_type>() <<endl;
|
cout << showType<TypeBinding<Join * const>::value_type>() <<endl;
|
||||||
cout << showType<TypeBinding<Join * const>::reference>() <<endl;
|
cout << showType<TypeBinding<Join * const>::reference>() <<endl;
|
||||||
cout << showType<TypeBinding<Join * const>::pointer>() <<endl;
|
cout << showType<TypeBinding<Join * const>::pointer>() <<endl;
|
||||||
|
|
||||||
|
cout << showType<int>() <<endl;
|
||||||
|
cout << showType<int&>() <<endl;
|
||||||
|
cout << showType<int&&>() <<endl;
|
||||||
|
cout << showType<int const&>() <<endl;
|
||||||
|
cout << showType<int const&&>() <<endl;
|
||||||
|
cout << showType<int const *>() <<endl;
|
||||||
|
cout << showType<int const * const>() <<endl;
|
||||||
|
cout << showType<int const * const&>() <<endl;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue