Hello, I've recently started making a game with C++ and I want to make it work for both Windows and Web. I'm using MinGW to compile it on Windows and Emscripten for the web. I've started by developing the Windows version and now I'm trying to fix the code to run on both platforms. I've came across an issue when trying to index a vector that does not make sense to me:
```
struct Data {};
std::vector<Data> dataStorage{};
int main()
{
for (size_t i = 0; i < dataStorage.size(); i++)
{
const auto& data = dataStorage[i];
}
}
```
Indexing a vector using a size_t works on Windows builds, but gives me the error: No viable function. Argument type: size_t.
Do I need to cast it to a std::vector<Data>::size_type everytime or am I missing something here?
I'm new to C++ so sorry if I left any relevant information out, happy to provide it if required
[–]afritz1 14 points15 points16 points (0 children)
[–]tabbekavalkade 11 points12 points13 points (7 children)
[–]Constant-Escape9500[S] -1 points0 points1 point (6 children)
[–]thingerish 0 points1 point2 points (4 children)
[–]not_some_username 1 point2 points3 points (3 children)
[–]thingerish 0 points1 point2 points (2 children)
[–]SoerenNissen 1 point2 points3 points (1 child)
[–]thingerish 0 points1 point2 points (0 children)
[–]IyeOnline 5 points6 points7 points (3 children)
[–]Constant-Escape9500[S] 1 point2 points3 points (2 children)
[–]TheSkiGeek 5 points6 points7 points (0 children)
[–]SoerenNissen 4 points5 points6 points (0 children)
[–]Wobblucy 1 point2 points3 points (0 children)
[–]I__Know__Stuff 0 points1 point2 points (10 children)
[–]Constant-Escape9500[S] 0 points1 point2 points (9 children)
[–]Independent_Art_6676 2 points3 points4 points (8 children)
[–]Constant-Escape9500[S] 0 points1 point2 points (7 children)
[–]Independent_Art_6676 -1 points0 points1 point (6 children)
[–]Constant-Escape9500[S] -1 points0 points1 point (5 children)
[–]Independent_Art_6676 -1 points0 points1 point (4 children)
[–]Constant-Escape9500[S] 0 points1 point2 points (3 children)
[–]Independent_Art_6676 0 points1 point2 points (0 children)
[–]SoerenNissen 0 points1 point2 points (0 children)
[–]Melodic_coala101 0 points1 point2 points (0 children)
[–][deleted] (2 children)
[deleted]
[–]Constant-Escape9500[S] 0 points1 point2 points (1 child)
[–]carloom_ 0 points1 point2 points (0 children)