F
Fokko Beekhof
Hello,
The following code compiles (gcc/linux/gnu platform)
//////////////////////
#include <tr1/array>
int main()
{
std::tr1::array<int, 7> a;
std::tr1::array<int, 6>::iterator i = a.begin()+1;
return 0;
}
/////////////////////
That it compiles is "logical" if you consider that what remains after
the first element of a an array of length 7, is an array of length 6.
It is also "illogical" if you consider that the iterator returned by
a.begin() is of type std::tr1::array<int, 7>::iterator, and merely
adding 1 to it should cause it to change its type.
Unless, of course, all iterators of type
std::tr1::array<int, X>::iterator are the same for all X.
Question: is it indeed guaranteed in the standard that all types
std::tr1::array<int, X>::iterator are identical for all X ?
Thanks in advance,
Fokko Beekhof
The following code compiles (gcc/linux/gnu platform)
//////////////////////
#include <tr1/array>
int main()
{
std::tr1::array<int, 7> a;
std::tr1::array<int, 6>::iterator i = a.begin()+1;
return 0;
}
/////////////////////
That it compiles is "logical" if you consider that what remains after
the first element of a an array of length 7, is an array of length 6.
It is also "illogical" if you consider that the iterator returned by
a.begin() is of type std::tr1::array<int, 7>::iterator, and merely
adding 1 to it should cause it to change its type.
Unless, of course, all iterators of type
std::tr1::array<int, X>::iterator are the same for all X.
Question: is it indeed guaranteed in the standard that all types
std::tr1::array<int, X>::iterator are identical for all X ?
Thanks in advance,
Fokko Beekhof