[Solution]
use typename when declaring the new alias:
using iterator = typename std::vector<DataStruct>::iterator;
[/solution]
This one is a bit convoluted…
The code below works:
template <class T>
class Something
{
public:
struct DataStructure
{
int a;
float b;
};
auto begin()
{
return indices.begin();
}
private:
std::vector<DataStructure>indices;
T data;
};
void main()
{
Something<int> thing;
auto i = thing.begin();
}
I would like to get rid of the auto, ideally by declaring an alias like so (inside the public section of Something):
using iterator = std::vector<DataStructure>::iterator;
Doing this causes the compiler error “syntax error: identifier ‘iterator’”
This doesn't happen if
a) The class is not a template class, or
b) The vector holds a native type instead of a class or struct
This is using C++17 in visual studio 2022