G
Greg
this template won't compile when used with bool, the erorr is
"invalid initialization of non const reference"
template < typename T >
class Vec : public std::vector< T > {
public:
Vec() { }
Vec( int s ) : std::vector<T>(s) { }
T& operator[](int i) { return this -> at(i); }
// <- this line
const T& operator[](int i) const { return this -> at(i); }
};
Vec<bool> b;
"invalid initialization of non const reference"
template < typename T >
class Vec : public std::vector< T > {
public:
Vec() { }
Vec( int s ) : std::vector<T>(s) { }
T& operator[](int i) { return this -> at(i); }
// <- this line
const T& operator[](int i) const { return this -> at(i); }
};
Vec<bool> b;