簡體   English   中英

錯誤:在沒有參數列表的情況下無效使用模板名稱“boost::asio::strand”

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

當我使用 cmake 和 boost 1.64.0 編譯 C++ 代碼和 boost 1.64.0 時,出現boost:: ASIO:: strand錯誤。我的操作系統是 Ubuntu。 這是我的 C++ 代碼:

#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;
    };


}

錯誤信息:

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.

如果您對這個問題有任何原始意見,請幫助我。

股線的界面發生了變化。

這里最簡單的方法是將strand更改為any_io_executor ,它可以容納...任何執行器,包括一個 strand。

boost::asio::any_io_executor mSendStrand, mRecvStrand;

Boost 版本中存在一個非常小的 window,其中any_io_executor不存在,但strand<>已經是一個模板。 在這種情況下,我希望boost::asio::executor與當前的any_io_executor具有相同的語義。

有關記錄的接口更改,請參閱: 網絡 TS 兼容性

當我使用boost::asio::io_service::strand時,該錯誤不再發生。有關文檔化的接口更改,請參閱: Networking TS compatible

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM