Login Page - Create Account

Support Board


Date/Time: Fri, 26 Apr 2024 23:57:29 +0000



Post From: std::map is causing CPU exception

[2021-04-19 02:03:21]
User641030 - Posts: 13
Hi,

I'm on SC version 2245 64-bit.

I'm writing a custom study that creates a simple map inside a class. The map insert method is throwing a warning: The custom dll 'name...' has just caused a CPU exception. It does not proceed after the warning.

I'm using Visual studio 2019 16.9.4 to build it locally.

I've pasted snippets of code relevant to the issue:

############## Creating object in sc.SetDefaults #################

TestClass* testObj= (TestClass*)sc.GetPersistentPointer(1);

if (testObj == NULL){
testObj = (TestClass*) new TestClass;
if( testObj != NULL)
sc.SetPersistentPointer(1, testObj);
else
return;
}

testObj.inputValue(1.0, 1.0)


########## TestClass #########

class TestClass{
std::map<float, float> testMap;

public:
TestClass();
void inputValue(SCStudyInterfaceRef sc, float low, float high);
}

In an instance method, I insert values into the Map

void TestClass::inputValue(SCStudyInterfaceRef sc, float low, float high){
testMap.insert(std::pair<float, float>(low, high));
}

Any help is much appreciated.

Thank you