I am trying to push value from a global vector to a local vector which is declared within a detached thread context. When i am trying to push the value like this:-
1 sensor_topolgy_contnr 2 tmp_sensor_topolgy_contnr
std::vector<sensor_modl_cred> tmp_sensor_topolgy_contnr;
std::vector<std::pair<std::string,sensor_modl_cred>> sensor_topolgy_contnr;
std::thread sensor_th(
[=]() {
tmp_sensor_topolgy_contnr.push_back(sensor_topolgy_contnr[sensor_itr].second);
this the thread within which i am pushing the local vector and this thread is enclosed by another detached thread (both of the threads are detached) 1 sensor_topolgy_contnr is globally declared vector 2 tmp_sensor_topolgy_contnr is locally declared vector within detached thread i get compilation error :-
error: passing ‘const std::vector’ as ‘this’ argument discards qualifiers [-fpermissive] tmp_sensor_topolgy_contnr.push_back(sensor_topolgy_contnr[sensor_itr].second);
I can't figure out why i am getting this error i am doing this operation within a detached thread and i have not declared the local thread as constant but still i am getting this error.What should i do in this scenario.