Re: Iterators and ints get confused in template parameter
James Kanze wrote:
The code in question is filled with names starting with _ and
__, for example:
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
This seems to be telling me that this is not standard library code,
Why?
Does the C++ standard really specify templates like std::__is_integer?
If not, then the code above is specific to the library in question and
thus not portable all in itself.
It's part of the implementation, so it's bound to use
funny names. But it's part of the implementation of the
standard library.
My point is: I want to replicate the functionality, but I can't just
copy it verbatim from gcc's library because it uses non-standard types
like the ones in the above example line.
but code specific to gcc (or whatever STL library it's using).
Thus it wouldn't probably be very portable to try to copy this
implementation verbatim.
Maybe, maybe not.
Unless the C++ standard specifies things like std::__is_integer, the
answer is no.
The only thing I could do is to copy the functionality of that type
(and whatever it might use) into my code, but I was wondering if there
isn't any easier way.
It's possible that the g++ library uses some
special g++ extensions here, but somehow I doubt it. And it
certainly can be done in standard C++. (The standard requires
it be done somehow, of course.)
I don't think you really understood what I meant.
template<>
struct IntegerDiscriminator< int >
{
typdef True Type ;
}
Doesn't that only take care of the case where the parameter is of type
'int'? What about unsigned int, long, unsigned long, short, unsigned
short, char, signed char, unsigned char, long long, unsigned long long...
Or something like that. For all the details, see the
Vandevoorde and Josuttis.
I didn't understand that.