简体   繁体   中英

error: invalid use of template-name ‘boost::asio::strand’ without an argument list

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.

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, but strand<> was already a template. In that case I expect that boost::asio::executor is available with the same semantics as current any_io_executor .

For the documented interface changes see: Networking TS compatibility

When i use boost::asio::io_service::strand the error no longer occurs。 For the documented interface changes see: Networking TS compatibility

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