I
Ivan
Recently, I read a simple code in the book C++ Templates. Bellow is
the code:
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(...); //Here, what
does ... mean?
public:
enum { Yes = sizeof(IsClassT<T>::test<T>(0)) == 1 };
enum { No = !Yes };
};
In code, I don't know clear what ... means? But I guess it as:
1) ... means variable argument. But as I known, variable argument is a
placeholder of arguments which must be placed after the last named
argument in C language. Is this ture in C++? if so, ... doesn't means
variable argument.
2) ... means wildcard argument. In function overload, if any function
test can't be selected in overload resolution, then the one with ...
as paramenter will be selected.
My guess 1) or 2) is right? If don't, I need your explanation. Thanks!
the code:
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(...); //Here, what
does ... mean?
public:
enum { Yes = sizeof(IsClassT<T>::test<T>(0)) == 1 };
enum { No = !Yes };
};
In code, I don't know clear what ... means? But I guess it as:
1) ... means variable argument. But as I known, variable argument is a
placeholder of arguments which must be placed after the last named
argument in C language. Is this ture in C++? if so, ... doesn't means
variable argument.
2) ... means wildcard argument. In function overload, if any function
test can't be selected in overload resolution, then the one with ...
as paramenter will be selected.
My guess 1) or 2) is right? If don't, I need your explanation. Thanks!