Reputation: 21
When I compiled C++ code with cmake and boost 1.64.0, a boost:: ASIO:: strand
error occurred.My OS is Ubuntu 18.04.
Here is my C++ Code:
#pragma once
// This file and the associated implementation has been placed in the public domain, waiving all copyright. No restrictions are placed on its use.
#include "Common/Defines.h"
#include <deque>
#include <mutex>
#include <future>
#include "Network/BtIOService.h"
namespace osuCrypto {
class WinNetIOService;
class ChannelBuffer;
class BtSocket
{
public:
BtSocket(BtIOService& ios);
boost::asio::ip::tcp::socket mHandle;
boost::asio::strand mSendStrand, mRecvStrand; //Error line
std::deque<BoostIOOperation> mSendQueue, mRecvQueue;
bool mStopped;
std::atomic<u64> mOutstandingSendData, mMaxOutstandingSendData, mTotalSentData, mTotalRecvData;
};
}
ERROR infomation:
In file included from /root/project/MultipartyPSI/MultipartyPSI/cryptoTools/Network/BtAcceptor.h:8:0,
from /root/project/MultipartyPSI/MultipartyPSI/cryptoTools/Network/BtEndpoint.h:5,
from /root/project/MultipartyPSI/MultipartyPSI/frontend/OtBinMain.cpp:1:
/root/project/MultipartyPSI/MultipartyPSI/cryptoTools/Network/BtSocket.h:76:9: error: invalid use of template-name ‘boost::asio::strand’ without an argument list
boost::asio::strand mSendStrand, mRecvStrand;
^~~~~
compilation terminated due to -Wfatal-errors.
If you have any original views on this problem, please help me.
Upvotes: 0
Views: 226
Reputation: 21
When i use boost::asio::io_service::strand
the error no longer occurs。
For the documented interface changes see: Networking TS compatibility
Upvotes: 1
Reputation: 393577
The interface for strands changed.
The simplest approach here will be to change strand
into any_io_executor
which can hold ... any executor, including a strand.
boost::asio::any_io_executor mSendStrand, mRecvStrand;
There exists a very small window of Boost releases where
any_io_executor
didn't exist, butstrand<>
was already a template. In that case I expect thatboost::asio::executor
is available with the same semantics as currentany_io_executor
.
For the documented interface changes see: Networking TS compatibility
Upvotes: 0