Quote from Boost listing list article by Arkady Vertlib:
God only knows what else can be found inside this compiler if you want to dig real depth.
, RSDN ( ) typeof() , , , .
? -, - "" Visual ++ , , , "" , typeof().
Microsoft- "" , . , , Microsoft, , . , , , :
http://rsdn.ru/Forum/?mid=1094305
, :
#include "stdafx.h"
template<int ID>
class CTypeRegRoot
{
public:
class id2type;
};
template<typename T, int ID>
class CTypeReg : public CTypeRegRoot<ID>
{
public:
class CTypeRegRoot<ID>::id2type
{
public:
typedef T Type;
};
typedef void Dummy;
};
template<int N>
class CCounter;
template<typename TUnused, int NTested = 0>
class CCountOf
{
public:
enum
{
__if_exists(CCounter<NTested>) { count = CCountOf<TUnused, NTested + 1>::count }
__if_not_exists(CCounter<NTested>) { count = NTested }
};
};
template<class TTypeReg, class TUnused, int NValue>
class CProvideCounterValue
{
public:
enum { value = NValue };
};
#define type_id(type) \
(CProvideCounterValue< \
typename CTypeReg<type, CCountOf<type >::count>::Dummy, \
CCounter<CCountOf<type >::count>, \
CCountOf<type >::count \
>::value)
class __Increment_type_id { enum { value = type_id(__Increment_type_id) }; };
template<int NSize>
class sized
{
private:
char m_pad[NSize];
};
template<typename T>
typename sized<type_id(T)> VarTypeID(T&);
template<typename T>
typename sized<type_id(const T)> VarTypeID(const T&);
template<typename T>
typename sized<type_id(volatile T)> VarTypeID(volatile T&);
template<typename T>
typename sized<type_id(const volatile T)> VarTypeID(const volatile T&);
#define var_type_id(var) \
(sizeof(VarTypeID(var)))
#define type_of(expression) \
\
CTypeRegRoot<var_type_id(expression)>::id2type::Type
#define auto_operator(arg1, arg2, op) \
type_of(instance(arg1) op instance(arg2)) operator op
class A
{
public:
friend static const char* operator +(const A& a, const A& b)
{
return "chijik-pijik";
}
};
template<typename T>
class Plus
{
public:
friend static type_of(T() + T()) operator +(const Plus<T>& a, const Plus<T>& b)
{
return a.m + b.m;
}
T m;
};
int _tmain(int argc, _TCHAR* argv[])
{
Plus<A> a1, a2;
const char* x = a1 + a2;
return 0;
}
, , , , MSVC 7.x. , . , ?
hth.,