#include <vector>
#include <algorithm>
#include <mutex>
+#include <cassert>
namespace AxWin {
{
// Allocate a window ID
::std::lock_guard<std::mutex> lock(glWindowList);
- int id = ::std::find(gWindowList.begin(), gWindowList.end(), nullptr) - gWindowList.end();
+ int id = ::std::find(gWindowList.begin(), gWindowList.end(), nullptr) - gWindowList.begin();
if( id >= MAX_WINDOW_ID ) {
throw ::std::runtime_error("AxWin4_CreateWindow - Out of IDs (TODO: Better exception)");
}
{
gWindowList.push_back(nullptr);
}
+ assert(gWindowList[id] == nullptr);
// Create window structure locally
tAxWin4_Window *ret = new tAxWin4_Window();