Hi,
This snippet is from the std::vector class:
template<class _Ty, class _A = allocator<_Ty> >
class vector {
public:
typedef vector<_Ty, _A> _Myt;
typedef _A allocator_type;
typedef _A::size_type size_type;
typedef _A::difference_type difference_type;
typedef _A::pointer _Tptr;
typedef _A::const_pointer _Ctptr;
typedef _A::reference reference;
typedef _A::const_reference const_reference;
typedef _A::value_type value_type;
typedef _Tptr iterator;
typedef _Ctptr const_iterator;
typedef reverse_iterator<const_iterator, value_type,
const_reference, _Ctptr, difference_type>
const_reverse_iterator;
typedef reverse_iterator<iterator, value_type,
reference, _Tptr, difference_type>
reverse_iterator;
explicit vector(const _A& _Al = _A())
: allocator(_Al), _First(0), _Last(0), _End(0) {}
explicit vector(size_type _N, const _Ty& _V = _Ty(),
.....
....
};
From this:
1) Does this imply that the 'allocator' class should have members/methods
called 'size_type', 'difference_type', 'value_type', etc. ?
What if someone deliberately passes in some class for _A (allocator),
which does not have 'size_type', etc? Will the compiler complain?
2) When are contructors made explicit?
I've already looked through some book on this, but it wasn't clear.
TIA,
SD