git-svn-id: svn://db.shs.com.ru/pip@469 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2017-04-25 12:38:43 +00:00
parent 7f2fa410cf
commit 826db9e87d
7 changed files with 266 additions and 68 deletions

View File

@@ -32,16 +32,77 @@ const char pult_config[] =
";
*/
#include <typeinfo>
template<typename T>
struct Info {
enum {Defined = 0};
};
template<typename T>
struct TypeInfo {
typedef T PureType;
typedef const T ConstPureType;
typedef T * PointerType;
typedef const T * ConstPointerType;
typedef T & ReferenceType;
typedef const T & ConstReferenceType;
};
#define TYPEINFO_SINGLE(PT, T) \
template<> struct TypeInfo<T> { \
typedef PT PureType; \
typedef const PT ConstPureType; \
typedef PT * PointerType; \
typedef const PT * ConstPointerType; \
typedef PT & ReferenceType; \
typedef const PT & ConstReferenceType; \
};
#define TYPEINFO(T) \
TYPEINFO_SINGLE(T, T &) \
TYPEINFO_SINGLE(T, const T) \
TYPEINFO_SINGLE(T, const T &) \
TYPEINFO_SINGLE(T, T *) \
TYPEINFO_SINGLE(T, const T *)
TYPEINFO(PIString)
template <typename T>
class A {
public:
void f() {
piCout << this;
piCout << "T";
}
};
template <typename T>
class A<const T&> {
public:
void f() {
piCout << "const T&";
}
};
int main(int argc, char *argv[]) {
PIVariant v;
A a = v.value<A>();
PIString s("123");
typedef PIString & MyT;
MyT i(s);
PIVariant v = PIVariant::fromValue(i);
piCout << v << v.value<__PIVariantTypeInfo__<MyT>::PureType>();
/*typedef PIString MyT;
piCout << typeid(MyT).name();
piCout << typeid(MyT&).name();
piCout << typeid(const MyT).name();
piCout << typeid(const MyT &).name();
piCout << typeid(MyT*).name();
piCout << typeid(const MyT*).name();
piCout << "";
piCout << typeid(TypeInfo<MyT>::PureType).name();
piCout << typeid(TypeInfo<MyT&>::PureType).name();
piCout << typeid(TypeInfo<const MyT>::PureType).name();
piCout << typeid(TypeInfo<const MyT&>::PureType).name();
piCout << typeid(TypeInfo<MyT*>::PureType).name();
piCout << typeid(TypeInfo<const MyT*>::PureType).name();*/
// v = PIVariant::fromValue(a);