- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我关注了this example设置异步 UDP 接收。但编译失败:
g++ -Wall -Wconversion -Wfatal-errors -Wextra -std=c++11 test1.cpp
错误信息:
In file included from /usr/include/c++/5/ext/alloc_traits.h:36:0,
from /usr/include/c++/5/bits/basic_string.h:40,
from /usr/include/c++/5/string:52,
from /usr/include/c++/5/stdexcept:39,
from /usr/include/c++/5/array:38,
from /usr/include/c++/5/tuple:39,
from /usr/include/c++/5/functional:55,
from /usr/include/c++/5/thread:39,
from test1.cpp:1:
/usr/include/c++/5/bits/alloc_traits.h: In instantiation of ‘static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::promise<long unsigned int>; _Args = {const std::allocator_arg_t&, std::allocator<void>}; _Tp = void; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<void>]’:
/usr/include/c++/5/bits/shared_ptr_base.h:522:39: required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {const std::allocator_arg_t&, std::allocator<void>}; _Tp = std::promise<long unsigned int>; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’
/usr/include/c++/5/bits/shared_ptr_base.h:617:4: required from ‘std::__shared_count<_Lp>::__shared_count(std::_Sp_make_shared_tag, _Tp*, const _Alloc&, _Args&& ...) [with _Tp = std::promise<long unsigned int>; _Alloc = std::allocator<void>; _Args = {const std::allocator_arg_t&, std::allocator<void>}; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’
/usr/include/c++/5/bits/shared_ptr_base.h:1097:35: required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {const std::allocator_arg_t&, std::allocator<void>}; _Tp = std::promise<long unsigned int>; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’
/usr/include/c++/5/bits/shared_ptr.h:319:64: required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {const std::allocator_arg_t&, std::allocator<void>}; _Tp = std::promise<long unsigned int>]’
/usr/include/c++/5/bits/shared_ptr.h:620:39: required from ‘std::shared_ptr<_Tp1> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = std::promise<long unsigned int>; _Alloc = std::allocator<void>; _Args = {const std::allocator_arg_t&, std::allocator<void>}]’
/usr/include/boost/asio/impl/use_future.hpp:39:56: required from ‘boost::asio::detail::promise_handler<T>::promise_handler(boost::asio::use_future_t<OtherAllocator>) [with Allocator = std::allocator<void>; T = long unsigned int]’
/usr/include/boost/asio/async_result.hpp:62:21: required from ‘boost::asio::detail::async_result_init<Handler, Signature>::async_result_init(Handler&&) [with Handler = const boost::asio::use_future_t<>&; Signature = void(boost::system::error_code, long unsigned int)]’
/usr/include/boost/asio/datagram_socket_service.hpp:410:51: required from ‘typename boost::asio::async_result<typename boost::asio::handler_type<WriteHandler, void(boost::system::error_code, long unsigned int)>::type>::type boost::asio::datagram_socket_service<Protocol>::async_receive_from(boost::asio::datagram_socket_service<Protocol>::implementation_type&, const MutableBufferSequence&, boost::asio::datagram_socket_service<Protocol>::endpoint_type&, boost::asio::socket_base::message_flags, ReadHandler&&) [with MutableBufferSequence = boost::asio::mutable_buffers_1; ReadHandler = const boost::asio::use_future_t<>&; Protocol = boost::asio::ip::udp; typename boost::asio::async_result<typename boost::asio::handler_type<WriteHandler, void(boost::system::error_code, long unsigned int)>::type>::type = std::future<long unsigned int>; boost::asio::datagram_socket_service<Protocol>::implementation_type = boost::asio::detail::reactive_socket_service<boost::asio::ip::udp>::implementation_type; boost::asio::datagram_socket_service<Protocol>::endpoint_type = boost::asio::ip::basic_endpoint<boost::asio::ip::udp>; boost::asio::socket_base::message_flags = int]’
/usr/include/boost/asio/basic_datagram_socket.hpp:897:51: required from ‘typename boost::asio::async_result<typename boost::asio::handler_type<WriteHandler, void(boost::system::error_code, long unsigned int)>::type>::type boost::asio::basic_datagram_socket<Protocol, DatagramSocketService>::async_receive_from(const MutableBufferSequence&, boost::asio::basic_datagram_socket<Protocol, DatagramSocketService>::endpoint_type&, ReadHandler&&) [with MutableBufferSequence = boost::asio::mutable_buffers_1; ReadHandler = const boost::asio::use_future_t<>&; Protocol = boost::asio::ip::udp; DatagramSocketService = boost::asio::datagram_socket_service<boost::asio::ip::udp>; typename boost::asio::async_result<typename boost::asio::handler_type<WriteHandler, void(boost::system::error_code, long unsigned int)>::type>::type = std::future<long unsigned int>; boost::asio::basic_datagram_socket<Protocol, DatagramSocketService>::endpoint_type = boost::asio::ip::basic_endpoint<boost::asio::ip::udp>]’
test1.cpp:25:28: required from here
/usr/include/c++/5/bits/alloc_traits.h:530:4: error: ‘using allocator_type = class std::allocator<void> {aka class std::allocator<void>}’ has no member named ‘construct’
{ __a.construct(__p, std::forward<_Args>(__args)...); }
^
代码:
#include <thread>
#include <iostream>
#include <future>
#include <boost/array.hpp>
#include <boost/asio/use_future.hpp>
#include <boost/asio.hpp>
int main()
{
boost::asio::io_service ioserv;
boost::asio::ip::udp::endpoint ep(boost::asio::ip::udp::v4(),(ushort)1414);
boost::asio::ip::udp::socket mysocket(ioserv,ep);
boost::asio::socket_base::reuse_address option(true);
mysocket.set_option(option);
boost::asio::ip::udp::endpoint sender_ep;
while(1)
{
std::array<char, 128> recv_buf;
boost::asio::ip::udp::endpoint sender_endpoint;
std::future<std::size_t> recv_length =
mysocket.async_receive_from(
boost::asio::buffer(recv_buf),
sender_endpoint,
boost::asio::use_future); // <<<< line 25: error
// Do other things here while the receive completes.
std::cout.write(
recv_buf.data(),
recv_length.get()); // Blocks until receive is complete.
}
return 0;
}
最佳答案
看起来这个错误已修复:
它看起来像是进入了 boost 1.60
关于c++ - ASIO UDP:类 std::allocator<void> 没有名为 ‘construct’ 的成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46166923/
这个问题在这里已经有了答案: Is Git’s "master" branch name more than just a name? (3 个回答) What will break if I don
我使用了Plone实例文件夹的“bin /”目录中的“paster”命令来创建一个名为“MyApp”的plone应用程序(来自模板),该命令是: (from instance's root folde
我正在尝试覆盖 FOSUserBundle 的用户映射的两个属性。 use FOS\UserBundle\Model\User as BaseUser; ... use Symfony\Bridge\
工作通过 these posts让我认为我了解自我类型,至少在某种程度上。 所以我创建了一个按预期失败的例子: scala> trait A { val v = "a" } defined trait
我在 IntelliJ 中有一个 JavaFX Maven 项目,它使用 Hibernate。当应用程序启动时,我收到以下错误消息: No persistence provider for entit
我正在尝试构建一个数据透视表,并使用开源代码并摸索着这个函数。record[] 如何传递给这个函数?似乎没有经过或任何声明。怎么能直接来呢? 完整代码可以在这里找到https://github.com
我的应用程序有 abc.com 链接,这是一个主页和 abc.com/user123(有一个动态部分),这是一个用户登录的特定配置文件页面。 早些时候,我通过这样做实现了这一点: this.route
当我在使用 mac book pro 的 Android Studio 上设置 Flutter Sdk 路径时,我遇到错误 Flutter SDK 路径未给出(并且打开一个弹出窗口并显示消息“名为‘F
我刚刚设置了 Postgres 供我网络上的不同用户使用。每个用户都有自己的用户名/密码/数据库,但是当我连接到 Pg 时,我还可以看到一个“postgres”数据库(甚至可以创建表等)。我试图从公众
我正在尝试从 MySQL 数据库中获取一些数据。所以我要做的是: select * from my_table where 'to' ='0000-00-00 00:00:00'; 这给了我空集,但我
我有一个名为“索引”的表。我意识到这是 MySQL 中的关键字,想知道如何在查询中引用该表? 我的错误: #1064 - You have an error in your SQL syntax; c
我在机器 myuniversity.edu 上设置了一个远程 mysql 数据库服务器,服务器名为“localhost”。我在上面有一个名为“MyDatabase”的数据库。 I want to co
我正在尝试使用 Android NDK 构建应用程序。我已按照所有步骤操作,一切正常,正在制作 .so 文件。但是在 Eclipse 中,当我尝试清理项目时出现以下错误: The file does
我正在重写 UIImage 类方法 init(named:)。我的目标是能够检索图像的文件名。 代码看起来像这样: class UIImageWithFileName: UIImage { l
@ThreadSafe public class A { } 这个注解实际上使类线程安全还是只是为了提高可读性? 最佳答案 参见 @ThreadSafe Annotation : Place this
当我将第二个表(dtResult)添加到数据集时出现错误 名为“Table”的数据表已属于此数据集。 DataTable dtSession = new DataTable(); DataTable
这个问题可能看起来重复,但略有不同。在 SO 的所有其他问题中,我注意到他们注册了多条路线。但就我而言,我只有一条路线。 我正在创建 asp.net webapi(框架 4.5)并且在 Registe
我最近将 Microsoft.AspNet.WebApi.WebHost 添加到 MVC WebAPI 项目中,这将允许我使用 [Route("api/some-action")] 归因于我的行动。我
我有一个名为“异常”的命名空间的问题 让我们考虑以下示例标题: #include namespace exception { struct MyException : public std::e
我昨天安装了 Nuget 1.2,今天,当我尝试安装 Entity Framework 包时,我在包管理器控制台中遇到了以下问题: PM> install-package entityframewor
我是一名优秀的程序员,十分优秀!