小编tun*_*2fs的帖子

如何在cmake目标中添加依赖项

我在cmake中定义了一个自定义目标.我现在想确保只在执行cmake目标时构建此目标test.我怎样才能做到这一点.

假设我有一个目标make coverage应该依赖于make test之前要调用的目标,或者make test在执行之前调用.

如何在cmake中定义此行为?

这里我的代码没有按预期工作.我想要实现覆盖取决于必须先调用make test.

    ADD_CUSTOM_TARGET(
        coverage COMMAND /bin/bash ${LIBPIPE_BINARY_DIR}/cmake/scripts/coverage.sh
        DEPENDS test
    )  
Run Code Online (Sandbox Code Playgroud)

cmake

4
推荐指数
2
解决办法
9435
查看次数

console.log 未显示预期的对象属性

我的 node.js 应用程序中有以下 javascript 代码。但是某些对象没有存储在我的变量中appointment。即使我设置了它们,当我直接访问它们时它也能工作:console.log(appointment.test);

我在这段代码中做错了什么?

var appointment = {
    subscribed: false,
    enoughAssis: false,
    studentSlotsOpen: false
};
console.log(appointment);
for (var key in appointmentsDB[i]) {
    appointment[key] = appointmentsDB[i][key];    
}

appointment.test= "res";

console.log(appointment.test);
console.log(appointment);
Run Code Online (Sandbox Code Playgroud)

这是产生的输出:

{ subscribed: false,
  enoughAssis: false,
  studentSlotsOpen: false }
res
{ comment: 'fsadsf',
  room: 'dqfa',
  reqAssi: 3,
  maxStud: 20,
  timeSlot: 8,
  week: 31,
  year: 2013,
  day: 3,
  _id: 51f957e1200cb0803f000001,
  students: [],
  assis: [] }
Run Code Online (Sandbox Code Playgroud)

该变量console.log(appointmentsDB[i])如下所示:

{ comment: 'fsadsf',
  room: 'dqfa',
  reqAssi: 3,
  maxStud: …
Run Code Online (Sandbox Code Playgroud)

javascript mongodb node.js

4
推荐指数
1
解决办法
2012
查看次数

模板类错误的复制构造函数被调用

为了避免std :: auto_ptr的问题,可以切换到boost :: shard_ptr或C++ 11 std :: shared_ptr.

我得到一个错误,在我的模板类中调用了错误的复制构造函数:

MPINetworkCode.hpp: error: no matching function for call to 
MPILib::MPINode<double>::MPINode(MPILib::MPINode<double>)

MPINode.hpp: note: candidate is: 
MPILib::MPINode<double>::MPINode(MPILib::MPINode<double>&)
Run Code Online (Sandbox Code Playgroud)

以下是导致此错误的代码行.

int MPINetwork<WeightValue>::AddNode(const AlgorithmInterface<WeightValue>& alg,
    NodeType nodeType) {

    MPINode<WeightValue> node = MPINode<WeightValue>(alg, nodeType, 
          tempNodeId, _nodeDistribution, _localNodes);
    _localNodes.insert(std::make_pair(tempNodeId, node));
}
Run Code Online (Sandbox Code Playgroud)

这段代码有什么问题,为什么调用错误的拷贝构造函数?在没有模板的此类的以前版本中,这工作正常.

这里是相关类的标题.模板实现位于头文件中.

这里是MPINetwork:

template <class WeightValue>
class MPINetwork: private boost::noncopyable {

public:

    explicit MPINetwork();

    ~MPINetwork();

    /**
     * Adds a new node to the network
     * @param alg The Algorithm of the actual node
     * @param nodeType …
Run Code Online (Sandbox Code Playgroud)

c++ templates

3
推荐指数
1
解决办法
266
查看次数

jQuery在解析html时添加了额外的标签

我有一个HTML字符串.因为我需要对它进行一些操作,我需要使用jquery.但是我有问题,jQuery在字符串中添加了额外的标签.我怎么能避免这种情况.

    var html = marked(input); //returns an html string
    console.log(html); //prints: <p>test<div>Type</div></p>
    var tree = $("<div>" + html + "</div>");
    //generate html out of the jquery html
    html = tree.html();
    console.log(html); // now it is: <p>test</p><div>Type</div><p></p>
Run Code Online (Sandbox Code Playgroud)

我用jQuery 2.0.3和浏览器测试了它的firefox和chrome.

html javascript jquery

3
推荐指数
1
解决办法
105
查看次数

枚举中的Visual Studio编译器错误

我有以下代码在Linux和Mac OS X下编译没有错误.我现在想用Windows编译代码,但是我在以下代码段中遇到了很多错误:

...
enum Type   
    {
        UPDATE = 0, DELETE = 1
    };
...
Run Code Online (Sandbox Code Playgroud)

错误消息是这些:

1>Request.hpp(48) : error C2143: syntax error : missing '}' before '('
1>Request.hpp(48) : error C2059: syntax error : '<L_TYPE_raw>'
1>Request.hpp(49) : error C2143: syntax error : missing ';' before '}'
1>Request.hpp(49) : error C2238: unexpected token(s) preceding ';'
Run Code Online (Sandbox Code Playgroud)

我错了什么,我真的很困惑,因为这在Linux下编译没有错误.什么可能导致这个错误?

c++ visual-studio visual-c++

1
推荐指数
1
解决办法
5903
查看次数

如果recv和send匹配,则mpi请求是否完成

是否足以从两个匹配的非阻塞发送和recv操作中仅检查一个请求对象.

这将是很好的,因为这将减少在我的程序中处理请求对象的工作量.

这里有一个使用boost mpi的小例子:

#include <boost/mpi.hpp>

int main(int argc, char* argv[]) {
    // initialize mpi

    mpi::environment env(argc, argv);
    boost::mpi::communicator world;
    boost::mpi::request req0, req1;
    double blub;
    if(world.rank()==1)
       req1 = world.irecv(0, 23, blub);
    if(world.rank()==0)
       req0 = world.isend(0, 23, blub);

    //now I want to synchronize the processors is this enough?
    req0.wait();
    //or do I also need this line
    req1.wait();

}
Run Code Online (Sandbox Code Playgroud)

c++ mpi boost-mpi

1
推荐指数
1
解决办法
766
查看次数