I'm in the design phase of a multi threading problem I might implement in c++. Will be the first time implementing something multi threaded in c++. The question is quite simple: If I have a function with a const parameter as input, is it just the function under consideration that is not allowed to alter it? Or does c++ guarantee that the parameter will not change (even if another thread tries to access it mid-function)?
void someFunction(const SomeObject& mustNotChange){
bool check;
if(mustNotChange.getNumber()==0) check == true; //sleep for 10s
if(check && mustNotChange.getNumber()!=0) //CRASH!!!
}
constobject leads to undefined behavior: eel.is/c++draft/dcl.dcl#dcl.type.cv-4.sentence-1.const X&can change in some way: lazy evaluation, function calls a callback which is modifying variable passed by argument. But his should not lead to a crash (indicated by code comment). Please provide more details of your problem: MORE CODE.