using namespace just for initialiser list

I have a lot of namespace usage in an initialiser list and would like a using namespace to reduce the verbosity. However the initialiser list is outside the scope of the constructor braces so I would have to place the using outside the constructor and pollute the rest of the file with it. Is there a way to scope the using as I want? Rather than: MyClass::MyClass() : m_one(nsConstants::ONE

只为初始化列表使用名称空间

我在初始化列表中有很多名称空间的用法,并希望使用名称空间来减少冗长。 然而,初始化列表超出了构造函数大括号的范围,因此我必须将构造函数外部的使用放在构造函数之外,并用它来污染文件的其余部分。 有没有办法根据需要来限制使用范围? 而不是: MyClass::MyClass() : m_one(nsConstants::ONE), m_two(nsConstants::TWO), m_three(nsConstants::THREE) {} 我想要: MyClass::MyClass() : using names

Hooking C++ Methods on OSX?

I am injecting a dylib in some application for some desired behavior. I am able to hook flat C APIs properly. Once I inject the dylib, I look out in symbol table and update its entry with my function address and in turn call the original one. Thus, symbol names becomes important to me. My problem is with C++ name mangling . How can we hook a C++ function whose name have been mangled. I r

在OSX上挂钩C ++方法?

我在某些应用程序中注入了dylib以获取某些期望的行为。 我能够正确挂接平面C API。 一旦我注入了dylib,我就会看到符号表,并用我的函数地址更新它的入口,然后调用原来的函数。 因此,符号名称对我来说变得重要。 我的问题是与C ++名称mangling 。 我们怎样才能钩住一个C ++函数的名字已经被损坏了。 我读了一些堆栈溢出的地方,它可能用mach_override挂钩c ++代码,但没有例子或引用。 有人可以举例说明如何实现C +

64bit interprocess communication

I am tasked with implementing an xml editor based on Win32 as a frontend process, while the business logic will be handled via a 64bit process. In addition the communication between the two processes will be done via a message bus which can only transmit messages of the form wchar_t * . (Yes it is so bad). Assuming you have only C++ 03 in your hands, no external library support eg Boost what

64位进程间通信

我的任务是将基于Win32的xml编辑器作为前端进程实现,而业务逻辑将通过64位进程处理。 另外,两个进程之间的通信将通过只能传输wchar_t *形式的消息的消息总线完成。 (是的,它很糟糕)。 假设你手中只有C++ 03 ,那么不需要外部库支持,例如Boost什么才是这项任务的最佳设计? 用例是用户只需编辑一些.xml文件。 我想在业务逻辑模块中有一个函数指针表,它处理不同的消息,然后返回到“监听”事件。 旁边的问题是否有任

Google Protocol Buffers: parseDelimitedFrom and writeDelimitedTo for C++

Sorry to ask this again, but could we please once and for all post some C++ functions that match the Java ones here? They don't seem to be getting added by google, and it is a quite a pain to write them yourself. Below answer using some of this and this. Here are the two basic versions with boost asio. Notice that to make this work properly, technically, in the second version, one would

Google Protocol Buffers:parseDelimitedFrom和writeDelimitedTo for C ++

很抱歉再次提出这个问题,但是我们可以一劳永逸地发布一些与Java相匹配的C ++函数吗? 他们似乎没有被谷歌添加,并且自己写这些是相当痛苦的。 下面回答一些这个和这个。 这里有两个基本版本升压asio。 从技术上讲,要使其在第二个版本中正常工作,需要查看缓冲区中的数据量,确定标题的大小(VarInt不是固定大小),但CodedInputStream具有GetDirectBufferPointer,用指针指向它的位置,所以从这个指针可以计算出剩余的消

Iterative Deepening Negamax with Alpha

I have a working negamax algorithm in my program. However, I need the program to find the best possible move within kMaxTimePerMove time. I did some research, and it seemed that using iterative deepening with my negamax algorithm would be the best way to do so. Right now, my function that starts the search looks like this: // this is a global in the same scope as the alpha-beta functions, so

使用Alpha迭代深化Negamax

我的程序中有一个有效的negamax算法。 但是,我需要该程序在kMaxTimePerMove时间内找到最佳移动。 我做了一些研究,似乎用我的negamax算法迭代加深是最好的方法。 现在,我开始搜索的功能如下所示: // this is a global in the same scope as the alpha-beta functions, so they can check the elapsed time clock_t tStart; int IterativeDeepening(Board current_state) { bool overtime = false; int depth = 0;

MiniMax with Alpha Beta Pruning for Othello not working

I have the following implementation of a alpha beta minimax for an othello (reversi) game. Somehow, this never really returns the proper action to take. It seems to return the default action I put in the function (0, 0) and the secondary value of -32768, which means it got pruned at the MAX subroutine. Any tips on what I can improve with this and how I can fix this problem? Note: I've id

带Alpha Beta修剪功能的MiniMax适用于奥赛罗不起作用

我有以下实现alpha beta minimax的奥西奥(reversi)游戏。 不知何故,这永远不会真正返回正确的行动。 它似乎返回了我放入函数(0,0)的默认动作和-32768的二级值,这意味着它在MAX子程序中被修剪。 任何提示,我可以改善这个以及我如何解决这个问题? 注意:我已经确定了大部分的正确退回的后继者。 现在的最大深度为8.电脑玩家的pn(玩家数量)为1,人类玩家为0.第一阶段0为MINIMAX_MAX。 Alpha和beta最初分别设置为I

Implementing Alpha Beta into Minimax

I'm trying to add Alpha Beta pruning into my minimax, but I can't understand where I'm going wrong. At the moment I'm going through 5,000 iterations, where I should be going through approximately 16,000 according to a friend. When choosing the first position, it is returning -1 (a loss) whereas it should be able to definitely return a 0 at this point (a draw) as it should be ab

将Alpha Beta纳入Minimax

我正在尝试将Alpha Beta修剪添加到我的minimax中,但我无法理解我要出错的地方。 目前我正在经历5000次迭代,根据一位朋友的说法,我应该经历约16,000次迭代。 当选择第一个位置时,它返回-1(一个损失),但它应该能够在这一点(一个平局)肯定地返回一个0,因为它应该能够从一个空白的棋盘上抽取,但是我看不到在我按照我的代码看起来很好的时候,我会出错 奇怪的是,如果我在我的支票中切换返回Alpha和Beta(实现返回0)

No breadcrumbs support for eclipse

I'm so used to working with Eclipse for java related projects that I thought I'd work with Eclipse CDT for C-projects too. 'Show in Breadcrumbs' was a nifty little feature that would show what method the cursor currently is at (in Eclipse JAVA). I don't see that option in Eclipse CDT. Is it in some way, hard to implement? The closest I could find to using the breadcrumbs

没有面包屑支持日食

我非常习惯于使用Eclipse来处理java相关的项目,我认为我也可以使用Eclipse CDT来处理C项目。 '在面包屑中显示'是一个漂亮的小功能,可以显示光标当前所处的位置(在Eclipse JAVA中)。 我在Eclipse CDT中看不到这个选项。 它在某种程度上很难实现吗? 我能找到的最接近使用面包屑功能的是: 转到“大纲”窗格,打开其菜单(向下箭头的右上方),然后选中“Link With Editor”框。 现在,方法名称将突出显示,以与光

OpenMPI Reduce using MINLOC

I'm currently working on some MPI code for a graph theory problem in which a number of nodes can each contain an answer and the length of that answer. To get everything back to the master node I'm doing an MPI_Gather for the answers and am attempting to do an MPI_Reduce using the MPI_MINLOC operation to figure out who had the shortest solution. Right now my datatype that stores the leng

OpenMPI使用MINLOC减少

我目前正在研究一些图论问题的MPI代码,其中许多节点都可以包含答案和答案的长度。 为了让所有事情回到主节点,我正在为MPI_Gather做出答案,并尝试使用MPI_MINLOC操作来执行MPI_Reduce来确定谁拥有最短的解决方案。 现在我的数据类型存储的长度和节点ID被定义为(每个例子显示在许多网站上,如http://www.open-mpi.org/doc/v1.4/man3/MPI_Reduce.3.php): struct minType { float len; int index; }; 在每个节点上

MongoDB: what is the most efficient way to query a single random document?

I need to pick a document from a collection at random (alternatively - a small number of successive documents from a randomly-positioned "window"). I've found two solutions: 1 and 2 . The first is unacceptable since I anticipate large collection size and wish to minimize the document size. The second seems ineffective (I'm not sure about the complexity of skip operation). An

MongoDB:查询单个随机文档的最有效方法是什么?

我需要随机选择一个文档(或者是随机定位的“窗口”中的少量连续文档)。 我找到了两个解决方案: 1和2 。 第一个是不可接受的,因为我预计收集量很大,希望尽量减少文档大小。 第二个似乎无效(我不确定skip操作的复杂性)。 在这里可以找到一个查询指定索引的文档,但我不知道该怎么做(我使用的是C ++驱动程序)。 是否有其他解决方案? 哪种效率最高? 我曾经有过类似的问题。 就我而言,我在文档上有一个日期属性。