how do i make an void *somethingobject in standard c ++? In particular, I want to use void *userdata
upstd::map<String, void*>
Is it possible? I'm trying to:
std::map <String, void*> user_data_n;
user_data_n = static_cast<std::map<String, void *>>(*user_data);
ERRORS:
Spurious '>>' user '>' to terminate a template argument list
Expected '>' before '(' token
'void *' is not a pointer-to-object type
or is there a better way to transfer information about the object of the caller and some other parameters that I can pass to void *user_data?
UPDATE:
Ass, suggested by @aaa carp, I changed >>to > >, and the first two errors were resolved. The last is strange: why do I get such a message when using it, and not when setting this object when setting up a callback?
std::map<String, void*> user_data_h;
user_data_h["Object"] = this;
user_data_h["h"] = h;
createTrackbar("trackbar_H", winName, h, 255, trackbar_handler, &user_data_h);
where createTrackbar is defined as:
int createTrackbar( const string& trackbarname, const string& winname,
int* value, int count, TrackbarCallback onChange, void* userdata);
UPDATE2:
, , , , ?
void trackbar_handler(int value, void *user_data){
std::map <String, void*> *user_data_map;
user_data_map = reinterpret_cast<std::map<String, void *> *>(user_data);
MainController *controller;
controller = reinterpret_cast<MainController *>( user_data_map["Object"]);
int *var = reinterpret_cast<int*> (user_data_map["h"]);