C++ // 将 Boost::array 传递给 Boost::thread

C++ // pass a Boost::array to Boost::thread

本文关键字:Boost thread array C++      更新时间:2023-10-16

我想将"boost::array"传递给"booth::thread"作业。

typedef unsigned char BYTE;
boost::array<BYTE,256> readBuffer;
thread gojob(&thread_job, readBuffer.data() );

如何通过?

void serial::thread_job(BYTE *received) {
}

写了这个..但编译只给了我奇怪的信息..我听不懂他在说什么。

include/boost/bind/mem_fn.hpp:333:36: error: cannot apply member pointer ‘((const boost::_mfi::dm<void(unsigned char*), serial>*)this)->boost::_mfi::dm<void(unsigned char*), serial>::f_’ to ‘* boost::get_pointer<unsigned char>(((unsigned char*)u))’, which is of non-class type ‘unsigned char’

传递缓冲区,然后处理 data(),你可以执行以下操作:

thread gojob(boost::bind(&serial::thread_job,this, boost::ref(readBuffer))