简体   繁体   中英

Thread - No matching function to call

I have a function called send

void send ( mutex *m,
            socklen_t addr_size, 
            sockaddr_storage serverStorage,
            double PLP ,
            int size_of_file ,
            char ** char_file , 
            int *total ,
            int *next_seq_to_send ,
            int *base_seq , 
            int client_socket , 
            int *window_size ,  
            vector <packet> *window_buffer , 
            vector <bool> *wind_slots )

I want to use this function to create a thread like this

std::thread send_thread (send, &m ,addr_size, 
                         serverStorage, PLP , size_of_file,
                         char_file , &total,
                         &next_seq_to_send,  
                         &base_seq, client_socket,   
                         &window_size,&window_buffer, 
                         &wind_slots );

But i got an error

no matching function for call to ‘std::thread::thread(<unresolved overloaded function type>, std::mutex*, socklen_t&, sockaddr_storage&, double&, int&, char*&, int*, int*, int*, int&, int*, std::vector<packet>*, std::vector<bool>*)’
 rage, PLP , size_of_file , char_file , &total , &next_seq_to_send , &base_seq , client_socket , &window_size , &window_buffer , &wind_slots );
                                                                                                                                             ^

Any help?

std::ref is used when you need to pass an object into the thread function (or in similar cases) by reference. That's not your case, though; the function doesn't accept references, it accepts pointers (and takes them by value). Just change all your uses of std::ref(x) into &x to take the arguments' addresses, and you should be good.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM