Win7 Cygwin
This the first time I've used templates & containers. I don't understand the errors. To my (naive) way of looking at things, I have defined an allocator (_Alloc) and a typdef (allocator_Type). The messages appear to be saying that I haven't done my homework properly. I have no clue as to what to do.
The code is:
template<typename T, typename _Alloc = std::allocator<T>>
class Array : public vector<T, _Alloc> {
public:
typedef T value_type;
typedef _Alloc allocator_Type;
private:
int compar (const void* p1, const void* p2) { T v1 = (T)*p1;
T v2 = (T)*p2;
return (v1 < v2)? -1: (v1 > v2)? 1: 0; }
public:
explicit Array (const allocator_Type& alloc = allocator_type()) : vector<T, _Alloc>(alloc) { };
explicit Array (size_t n) : vector<T, _Alloc>(n) { };
Array (size_t n, const T& val,
const allocator_type& alloc = allocator_type()): vector<T, _Alloc>(n, val, alloc) { };
};
The error messsages are:
main.cpp:31:27: error: 'allocator_type' does not name a type
const allocator_type& alloc = allocator_type()): vector<T, _Alloc>(n, val, alloc) { };
^
main.cpp:31:27: note: (perhaps 'typename std::vector<_Tp, _Alloc>::allocator_type' was intended)
main.cpp:31:66: warning: ISO C++ forbids declaration of 'alloc' with no type [-fpermissive]
const allocator_type& alloc = allocator_type()): vector<T, _Alloc>(n, val, alloc) { };
^
main.cpp:28:65: warning: there are no arguments to 'allocator_type' that depend on a template parameter, so a declaration of 'allocator_type' must be available [-fpermissive]
explicit Array (const allocator_Type& alloc = allocator_type()) : vector<T, _Alloc>(alloc) { };
^
main.cpp:31:66: warning: there are no arguments to 'allocator_type' that depend on a template parameter, so a declaration of 'allocator_type' must be available [-fpermissive]
const allocator_type& alloc = allocator_type()): vector<T, _Alloc>(n, val, alloc) { };
^