调用boost v1.58中的函数时出现模板名称使用无效错误
Invalid use of template name error when calling function in boost v1.58
我有一个利用boost库(版本1.58(的小型C++项目,在调用boost::asio::strand时出错。我的语法似乎是错误的,但我不知道怎么回事。
#pragma once
#ifndef TCPNETWORK_H_
#define TCPNETWORK_H_
//-----------------------------------------------------------------------------
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/shared_ptr.hpp>
#include <string>
#include <vector>
#include <list>
#include <boost/cstdint.hpp>
//-----------------------------------------------------------------------------
using boost::uint32_t;
using boost::uint16_t;
using boost::uint8_t;
using boost::int32_t;
using boost::int16_t;
using boost::int8_t;
//-----------------------------------------------------------------------------
class Hive;
class Acceptor;
//class Connection;
//-----------------------------------------------------------------------------
class Connection : public boost::enable_shared_from_this< Connection >
{
friend class Acceptor;
friend class Hive;
private:
boost::shared_ptr< Hive > m_hive;
boost::asio::ip::tcp::socket m_socket;
boost::asio::strand m_io_strand;
boost::posix_time::ptime m_last_time;
std::vector< uint8_t > m_recv_buffer;
std::list< int32_t > m_pending_recvs;
std::list< std::vector< uint8_t > > m_pending_sends;
int32_t m_receive_buffer_size;
boost::asio::deadline_timer m_retryTimer ;
int32_t m_retryTimerInterval;
boost::asio::deadline_timer m_connectTimer;
int32_t m_connectTimerInterval;
boost::asio::deadline_timer m_sendTimer;
int32_t m_sendTimerInterval;
void DispatchSendTimer( const boost::system::error_code & error );
void HandleSendTimer( const boost::system::error_code & error );
volatile uint32_t m_error_state;
我收到的错误消息与此代码中的以下行有关:
boost::asio::strand m_io_strand;
我收到的错误信息如下:
../include/TCPNetwork.h:53:9: error: invalid use of template-name ‘boost::asio::strand’ without an argument list
那么我应该如何引用m_io_strand?
应该编写boost::asio::io_service::strand
而不是boost::asio::strand
。此外,您应该在类的构造函数中使用io_service
对象初始化strand
。
相关文章:
- 错误:无效的预处理指令 #i 的意思是 #if?
- is_same和variadic模板编译时错误无效转换
- printf 和 strftime 的参数错误无效
- 错误:无效使用非静态成员函数"int test::hotplug_callback(libusb_contex
- 我收到一个错误无效的操作数,类型为 const char [42] 和二进制"运算符+"的双倍数
- 错误:无效使用无效
- 发布信号量返回错误 6(无效句柄)
- C++17 可选树,错误:无效使用不完整的类型
- C++ 线程函数指针实现返回错误无效使用非静态成员函数
- 在测试中使用unique_ptr时指针错误无效
- 使用 malloc 而不是 new 会导致 free():指针错误无效
- valgrind错误无效读数4
- X11 XGetImage badmatch错误(无效的参数属性)
- free():C++中的指针错误无效
- 使用 valgrind 的地图中的读取大小错误无效
- 错误:无效的基类C
- 错误:无效使用了void表达式C++
- C++链接错误.无效
- free()错误:无效的下一个大小(fast)
- 我收到错误"无效使用不完整的类型'class map'