#include
#include
#include
#include
#include
using namespace std;
void *do_work(void *buf){
//1.void* ---> vector
vector* p = (vector*)(buf);
printf("xxx---->%s(), line = %d, p->data() = %s, p->size() = %ldn",__FUNCTION__,__LINE__,p->data(),p->size());
//2.void* ---> vector
vector* pt = static_cast*>(buf);
printf("xxx---->%s(), line = %d, pt->data() = %s, pt->size() = %ldn",__FUNCTION__,__LINE__,pt->data(),pt->size());
}
int main(){
pthread_t td;
char buffer[] = "Hello anbox.";
vector data(buffer, buffer + strlen(buffer));
printf("data.data() = %sn",data.data());
//1.vector ---> void*
pthread_create(&td,NULL,do_work, (void*)(&data));
//2.vector ---> void*
//pthread_create(&td,NULL,do_work, static_cast(&data));
pthread_join(td, NULL);
}