I have a custom implementation for arrays with arbitrary upper and lower bounds. Now I want to be able to freely convert between arrays of the same type, as long as they have the same length. In code it looks like this:
template<typename T, int L, int H>
class Array{
public:
// stuff ...
operator Array<T, int lb, int hb>& () {
auto converted = Array<T, lb, hb>;
converted.actualArray = actualArray;
converted.offset = lb;
return *converted;
}
private:
T actualArray[H - L + 1];
int offset = 0 - L;
}
As you can see, the class needs to convert to itself. As you can probably also see, I am quite the noob at C++, as the error I'm given appears to be a syntax one:
wrong number of template arguments (2, should be 3)
operator Array<T, int lb, int hb>& () {
^
'<expression error>' does not name a type
operator Array<T, int lb, int hb>& () {
^
What am I doing wrong, that my operator's return type is not recognized? I really hope it's not a simple typo, that would be stupid.