草庐IT

boost-mpi

全部标签

c++ - 如何为 boost::tuple 编写一个 `<<` 运算符?

在下面的示例代码中,它表明可以从第一个模板参数隐式创建boost::tuple。因此,我无法写运算符,因为它变得模棱两可。我也不明白为什么ostringstream&也是模棱两可的。这没有任何隐式构造。为什么这也会产生模棱两可的错误?#include#include#include#includeusingnamespacestd;classMyclass{};typedefboost::tupleMytuple;ostringstream&operator();//os_();//ErrorbecauseintisimplicitlyconvertedintoMytuple.WHYY

c++ - Boost Gzip 过滤器 : compile failes

我正在尝试从BoostGzip过滤器页面编译示例:#include#include#include#include#includeintmain(){usingnamespacestd;ifstreamfile("hello.gz",ios_base::in|ios_base::binary);filtering_streambufin;in.push(gzip_decompressor());in.push(file);boost::iostreams::copy(in,cout);}遗憾的是我的g++返回错误:gzlib.cpp:Infunction‘intmain()’:gzli

c++ - 使用单独的 .h 和 .cpp 文件 boost 序列化

我正在试验boost序列化库,并且大部分都可以正常工作。唯一的问题是当我尝试序列化具有单独的.h和.cpp文件的对象时。当我使用这个命令编译时:g++boostSerialize.cppClass.cpp-lboost_serialization我收到这个错误:/tmp/cc8kbW6J.o:Infunction`voidboost::serialization::access::serialize(boost::archive::text_oarchive&,Class&,unsignedint)':boostSerialize.cpp:(.text._ZN5boost13seria

c++ - BOOST 线程 : cout behavior

我是Boost线程的新手,我对如何从多个线程执行输出感到困惑。我有一个简单的boost::thread从9倒数到1;主线程等待然后打印“LiftOff..!!”#include#includeusingnamespacestd;structcallable{voidoperator()();};voidcallable::operator()(){inti=10;while(--i>0){cout问题是我必须在线程中使用明确的“cout.flush()”语句来显示输出。如果我不使用flush(),我只会得到“LiftOff!!”作为输出。有人可以告诉我为什么我需要显式使用flush()

c++ - MPI_ERR_BUFFER : invalid buffer pointer

这个错误最常见的原因是什么MPI_ERR_BUFFER:invalidbufferpointerMPI_Bsend()和MPI_Rcev()调用的结果是什么?当并行进程数较少( 最佳答案 扩展我之前的评论:MPI中的缓冲可以在各种情况下发生。MPI库可以在内部缓冲消息以隐藏网络延迟(通常只对不超过实现相关大小的小消息进行缓冲)或者用户可以通过使用任何缓冲发送操作来强制执行缓冲MPI_Bsend()和MPI_Ibsend()。用户缓冲与内部缓冲不同:首先,由MPI_Bsend()或MPI_Ibsend()发送的消息总是被缓冲的,而内部

c++ - boost::call_traits - 为什么 gcc 为此给出 false?

示例:#include#include#includeboost::call_traits::param_typef(){return1;}intmain(){std::cout::param_type>::value::value问题:除非我做错了什么,我想我应该为两者都得到true,但是gcc4.7.0为后者输出false。有什么我想念的吗? 最佳答案 非类类型的右值永远不是const限定的。只有类类型的右值可以是const限定的。因此,即使函数f被声明为返回一个constint,即使函数f的类型是constint(),调用表达

c++ - 如何使用boost::spirit解析UTF-8?

#include#include#include#include#defineBOOST_SPIRIT_UNICODE//We'lluseunicode(UTF8)allthroughout#include#include#includevoidparse_simple_string(){namespaceqi=boost::spirit::qi;namespaceencoding=boost::spirit::unicode;//namespacestw=boost::spirit::standard_wide;typedefstd::wstring::const_iteratori

c++ - 在boost中为斐波那契堆定义比较函数

我需要在我的项目中使用Fibonacci堆,我正在尝试从boost库中使用它。但我不知道如何为任意数据类型设置用户定义的比较函数。我需要为结构节点构造一个最小堆,定义如下:structnode{intid;intweight;structnode*next;/*distisaglobalarrayofintegers*/booloperator>(structnodeb)//BoostgeneratesaMax-heap.WhatIneedisamin-heap.{returndist[id]".booloperatordist[b.id]?1:0;}booloperator>=(st

c++ - 尝试使用 boost::optional 失败

我一直在尝试将boostoptional用于可以返回对象或null的函数,但我无法弄清楚。这是我到目前为止所拥有的。任何有关如何解决此问题的建议都将不胜感激。classMyclass{public:inta;};boost::optionalfunc(inta)//ThiscouldeitherreturnMyClassoranull{boost::optionalvalue;if(a==0){//returnanobjectboost::optionalvalue;value->a=200;}else{returnNULL;}returnvalue;}intmain(intargc,

c++ - MPI中每个进程的随机数

我正在使用MPICH2来实现“奇偶”排序。我做了实现,但是当我随机分配给每个进程他的值时,相同的数字被随机分配给所有进程。这里是每个进程的代码,每个进程随机化了他的值..intmain(intargc,char*argv[]){intnameLen,numProcs,myID;charprocessorName[MPI_MAX_PROCESSOR_NAME];intmyValue;MPI_Init(&argc,&argv);MPI_Comm_rank(MPI_COMM_WORLD,&myID);MPI_Comm_size(MPI_COMM_WORLD,&numProcs);MPI_Ge