Boost Websocket - 非法使用类型"void"

Boost Websocket - illegal use of type 'void'

本文关键字:类型 void Websocket 非法 Boost      更新时间:2024-05-09

我正试图在我的应用程序中包含并编译一个boost 1.77.0 websocket。

// File.h
#include <boost/beast/core.hpp>
#include <boost/beast/websocket.hpp>

Boost是使用vcpkg(:x64 windows(安装的。当尝试编译时,我得到以下错误:

Error C2182 'executor_': illegal use of type 'void' - E:Githubvcpkginstalledx64-windowsincludeboostasioimplcompose.hpp Line 64

有人遇到过这个问题吗?找不到此问题上的任何内容。

我使用的是Visual Studio 16.11.5(C++17(。

注意:该项目包含.cu文件。这可能是问题所在吗?在单独的解决方案中编译头不会产生任何错误。

compose.hpp:的相关部分

template <typename Executor, typename = void>
class composed_work_guard
{
public:
typedef typename decay<
typename prefer_result<Executor,
execution::outstanding_work_t::tracked_t
>::type
>::type executor_type;
composed_work_guard(const Executor& ex)
: executor_(boost::asio::prefer(ex, execution::outstanding_work.tracked))
{
}
void reset()
{
}
executor_type get_executor() const BOOST_ASIO_NOEXCEPT
{
return executor_;
}
private:
executor_type executor_; // line 64
};

经过更多的研究,我设法解决了这个问题。我把boost代码放在另一个翻译单元中,这个单元不会被cuda编译器触及。