草庐IT

BOOST_STRONG_TYPEDEF

全部标签

c++ - Boost.asio 和异步链,unique_ptr?

我对异步编程不是很熟悉,我有一个问题。我的问题如下。给定boost.asio中C++11的echo_server示例:http://www.boost.org/doc/libs/1_60_0/doc/html/boost_asio/example/cpp11/spawn/echo_server.cpp我想知道std::make_shared可以在C++14中替换为std::unique_ptr在C++14中,避免了引用计数的开销。我不确定,因为我们有shared_from_this()但不是像unique_from_this()这样的东西,那么我怎样才能访问unique_ptr从里面t

c++ - 与 boost::property_tree XML 解析器一起使用时 boost::coroutine 库崩溃

我正在使用Simple-Web-Server用于创建将XML转换为JSON的简单Web服务的库,反之亦然。反过来,它使用了几个boost库以及其中的boost::coroutine。对于XMLJSON转换,我使用boost::property_tree库进行中间表示。这是代码:#include#include#include#defineBOOST_SPIRIT_THREADSAFE#include#include#includeusingnamespacestd;usingnamespaceboost::property_tree;usingHttpServer=SimpleWeb:

c++ - 是否可以使用强制编译器错误扩展 typedef?

我一直在使用下面显示的方法来强制编译器对我大喊一个变量类型:templatestructshow_type;将它与所需的变量一起使用,这样编译器就会错误地给出一个不完整的结构类型:typedefint32_ts32;s32a;show_type();因此GCC5.3.0产生错误:invaliduseofincompletetype'structshow_type'和MSVC2015:'show_type':noappropriatedefaultconstructoravailable现在我想知道是否有办法强制错误显示typedef的完整层次结构s(即s32->int32_t->int

带有概念的 C++ 别名模板(typedef)?

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4553.pdfgcc6:-f概念templateconceptboolString=requires(Ts){{s.clear()}->void;//etc.};voidprint(constString&message);//voidprint(Strmessage);//IwantStr=constString&voidtest(){std::stringstr;print(str);}有没有办法将Str声明为constString&? 最

c++ - 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error>>

我创建了客户端应用程序。当我发送单个消息clientsever时它工作正常。但是当我出于性能目的发送大量消息时,客户端会以两种不同的方式崩溃:(gdb)runStartingprogram:/home/x64joxer/workerGenerators/Worker2/worker-t-i192.168.0.6-p6000-d5-l//home/x64joxer/workerGenerators/Worker2/[Threaddebuggingusinglibthread_dbenabled]Usinghostlibthread_dblibrary"/lib/x86_64-linux-

c++ - 如何在 C++ 中预先声明一个 typedef 类

比如类A有类B的一个成员,一般情况下,为了最小化编译依赖,我们经常让类A包含类B的指针,并在类A的声明中预先声明类B。看起来像这样://B.hclassB{....};//A.hclassB;classA{B*b;A();...};//A.cpp#include"B.h"A::A(){b=newB();...};但现在我有一个问题:如果B的类是这样使用typedef定义的:typedefclass{....}B;先前预先声明的方法在这种情况下将不起作用。我应该如何在A.h中预先声明B类? 最佳答案 在代码typedefclass{.

c++ - 使用 Boost 库 Qt C++ 更新翻译文件

我在我的C++项目中使用Boost库。我将它包含在PRO文件中,如下所示:win32:INCLUDEPATH+=C:/boost_1_60_0win32:LIBS+="-LC:/boost_1_60_0/stage/lib/"但是,当我在终端(cmd)上运行以下命令来更新我的翻译文件时:lupdateMyProject.pro它在Boost库路径中搜索文件进行更新。这正常吗?我该怎么做才能不在Boost库路径中搜索?现在,当我需要运行lupdate命令时,我正在评论Boost包含行,但我不想每次需要更新我的翻译文件时都这样做。Qt5.3.2boost1.6.0

c++ - 为什么 Boost 原子使用中的多生产者队列是无等待的

BoostAtomic示例中的无等待多生产者队列:templateclasswaitfree_queue{public:structnode{Tdata;node*next;};voidpush(constT&data){node*n=newnode;n->data=data;node*stale_head=head_.load(boost::memory_order_relaxed);do{n->next=stale_head;}while(!head_.compare_exchange_weak(stale_head,n,boost::memory_order_release));

c++ - 如何使用 Boost.Spirit.Qi 增量解析(并作用于)大文件?

我为自定义文本文件格式创建了一个Qi解析器。有数以万计的条目要处理,每个条目通常有1-10个子条目。我放了一个精简的解析器工作示例here.#include#include#include#include#include#include#include#include#include#include#include#include#includeusingstd::string;usingstd::vector;usingstd::cout;usingstd::endl;namespacemodel{namespaceqi=boost::spirit::qi;structspectru

c++ - boost 收集范围的适配器

我想编写一个boost适配器放在适配器链的末尾以创建一个集合,如下所示:sets=input|filtered(...)|transformed(...)|to_set;使用Method3.1我写了下面的代码,它似乎按预期工作:namespacedetail{structto_set_forwarder{};};templateinlineautooperator|(R&r,detail::to_set_forwarder){returnset(r.begin(),r.end());}templateinlineautooperator|(constR&r,detail::to_set