I know that the operator sizeofdoes not evaluate its expression argument to get an answer. But this is not one of the non-deductible contexts for patterns. Therefore, I wonder how it interacts with templates and specifically subtracts template arguments. For example, the following are taken from C ++ templates: Complete Guide:
template<typename T>
class IsClassT {
private:
typedef char One;
typedef struct { char a[2]; } Two;
template<typename C> static One test(int C::*);
template<typename C> static Two test(...);
public:
enum { Yes = sizeof(IsClassT<T>::test<T>(0)) == 1 };
enum { No = !Yes };
};
This type function determines how its name indicates whether the template argument is a class type. The mechanism is essentially the following condition:
sizeof(IsClassT<T>::test<T>(0)) == 1
, (T ), - 0 int, pointer to an int member of class C. , T , - 0, static One test(int C::*); , (0 ) ( ?). SFINAE ,
static Two test(...);
, sizeof, , 0 .
- :
- ?
- ,
sizeof , 0 ? 0 , 0, 0.0, 100 ?
. ++ Primer, . " " " , ,
(§ 16.2.1, . 680),
, ". , 0 ( ).