小编seh*_*ehe的帖子

避免在Boost Log中使用漏洞

我从服务器端应用程序获得valgrind泄漏报告,该应用程序使用与boost 1.56一起分发的boostlog.valgrind报告是:

== 8021 == 1,159块中的37,088字节肯定会在1,642的损失记录1,613中丢失

== 8021 ==在0x4A05588:memalign(vg_replace_malloc.c:727)

== 8021 == by 0x3FDA61118F:tls_get_addr_tail(在/lib64/ld-2.12.so中)

== 8021 == by 0x3FDA61165F:__ tls_get_addr(在/lib64/ld-2.12.so中)

== 8021 == by 0x3FE6ABBDCB:__ cxa_get_globals(在/usr/lib64/libstdc++.so.6.0.13中)

== 8021 == by 0x730C528:boost :: log :: v2_mt_posix :: aux :: unhandled_exception_count()(在/opt/sesteksdk/lib/libboost_log.so.1.56.0中)

== 8021 == by 0x5D54D1F:sestek :: mrcp :: audio :: recognition :: AsynchronousRecognizer :: Notify(sestek :: voice :: recognition :: IRecognizerNotification const*)(record_ostream.hpp:259)

这种泄漏来自一条简单的线路:
LOGGER(debug)<< _chanProp->GetId() << " got recognition ended notification from recognizer";

我们从一次短暂的测试运行中得到了5个泄漏.

我们使用文本文件后端,同步接收器,自动刷新打开.基本上:

void InitializeFileLog(const std::string & logDir)
    { …
Run Code Online (Sandbox Code Playgroud)

c++ logging boost memory-leaks boost-log

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

为什么不在.vimrc中设置ts = 4?

我有一个愚蠢的问题,但我被困住了.我在.vimrc文件中设置了set ts = 4,但看起来不行.打开一个新文件,选项卡仍然扩展为3个空格.在命令模式下,"set ts"得到一个"tabstop = 3".是否有像.vimrc这样的最终文件覆盖我的ts?

甚至我输入:set ts = 4,在vim中,当我输入tab时,它只有3个空格.

这是我的可疑选项,导致我的.vimrc中的这个恼人的结果

set autoindent
set shiftwidth=4
set softtabstop=4
set backspace=2
Run Code Online (Sandbox Code Playgroud)

谢谢.

vim

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

Elasticsearch - 以更高的值提升嵌套查询

我有一个查询(很好的一部分 - 休息是不重要的像分页):

  "query": {
    "filtered": {
      "query": {
        "bool": {
          "must": [
            {
              "term": {
                "is_active": true
              }
            }
          ],
          "should": [
            {
              "bool": {
                "must": [
                  {
                    "nested": {
                      "path": "skills",
                      "query": {
                        "bool": {
                          "must": [
                            {
                              "bool": {
                                "must": [
                                  {
                                    "range": {
                                      "skills.value": {
                                        "gte": "2"
                                      }
                                    }
                                  },
                                  {
                                    "term": {
                                      "skills.skill.name": "php"
                                    }
                                  }
                                ]
                              }
                            }
                          ]
                        }
                      }
                    }
                  }
                ],
                "boost": 2
              }
            }
          ]
        }
      }
    }
  }
Run Code Online (Sandbox Code Playgroud)

这是用于搜索配置文件,其具有值为2或更高的技能"PHP".用户可以搜索多个技能=>值对.它工作正常,但我有一个问题: …

nested elasticsearch solr-boost

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

Boost图库中顶点描述符和索引之间有什么区别?

在Boost图库中,何时应该使用顶点描述符和何时使用索引?既然执行vertex_descriptor实际上是无符号整数,那么这两个东西是否具有相同的值?

c++ boost boost-graph

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

所有C++编译器都支持async/await关键字吗?

我想async/await在C++(UE4框架)中使用语法,但由于跨平台代码,我不确定是否可能......或者可能?如果是,我该如何使用它?

也有await__await(resumable,yield__yield_value也)在Visual Studio中突出显示的关键字.有什么区别?也许不是所有的编译器都支持这个关键字或单独支持?

gcc,clang是接受吗?或者不接受,我可以单独为每个平台使用宏.

c++ asynchronous cross-platform async-await unreal-engine4

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

图形可视化(增强图)

我有使用boost图库的C++程序.我想知道是否有任何方法可以在节点中包含的某个位置值之后可视化图形(节点和可选边).请查看下面的图像示例,以了解我想要想象的内容:http: //img11.hostingpics.net/pics/647608graphViz.png

谢谢.

c++ plot visualization graph boost-graph

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

RSPEC和工厂女孩SystemStackError:堆栈级别太深

我试图解决我的Spec测试的问题,我得到以下错误失败:

  1) SessionsController POST 'create' with valid email and password should sign in the user
     Failure/Error: Unable to find matching line from backtrace
     SystemStackError:
       stack level too deep
     # /Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:103

Finished in 37.77 seconds
9 examples, 1 failure

Failed examples:

rspec ./spec/controllers/sessions_controller_spec.rb:35 # SessionsController POST 'create' with valid email and password should sign in the user
Run Code Online (Sandbox Code Playgroud)

在此之前,我与工厂的关联存在问题.

Factory.define :role do |role|
  role.name                   "Registered"
  role.association :user, :factory => :user
end

Factory.define :admin do |role|
  role.name                   "Admin"
  role.association :user, :factory => :user …
Run Code Online (Sandbox Code Playgroud)

factory rspec ruby-on-rails factory-bot

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

地址

我试图找到this指针的地址,但这段代码显示一个奇怪的错误:

#include <iostream>
using namespace std;
class Base
{
    public:
        void test()
        {
            void *address_of_this =&this;
            cout<<address_of_this<<endl;
        }
};

int main()
{   Base k;
    k.test();

    return 0;
}   //error non-lvalue in unary'&'   
Run Code Online (Sandbox Code Playgroud)

你能解释一下这个错误吗?
还指出什么是非法的地址this

c++ pointers this

11
推荐指数
2
解决办法
2万
查看次数

来自语义动作的boost :: spirit访问位置迭代器

可以说我有这样的代码(行号作为参考):

1:
2:function FuncName_1 {
3:    var Var_1 = 3;
4:    var  Var_2 = 4;
5:    ...
Run Code Online (Sandbox Code Playgroud)

我想编写一个语法来解析这样的文本,将所有的标识符(函数和变量名)信息放入一个树(utree?).每个节点应保留:line_num,column_num和符号值.例:

root: FuncName_1 (line:2,col:10)
  children[0]: Var_1 (line:3, col:8)
  children[1]: Var_1 (line:4, col:9)
Run Code Online (Sandbox Code Playgroud)

我想将它放入树中,因为我计划遍历该树,并且对于每个节点,我必须知道"上下文":(当前节点的所有父节点).

例如,在使用Var_1处理节点时,我必须知道这是函数FuncName_1的局部变量的名称(当前正在作为节点处理,但是前一级)

我无法弄清楚一些事情

  1. 这可以通过语义动作和语言在Spirit中完成吗?或者我应该使用变体<>树?
  2. 如何同时将这三个信息(column,line,symbol_name)传递给节点?我知道我必须使用pos_iterator作为语法的迭代器类型,但如何在sematic动作中访问这些信息?

我是Boost的新手,所以我一遍又一遍地阅读Spirit文章,我试着谷歌我的问题,但我不知道怎么能把所有的部分放在一起找到解决方案.好像没有人像我之前那样有这样的用例(或者我只是无法找到它)看起来像位置迭代器的唯一解决方案是解析错误处理的那些,但事实并非如此我感兴趣的.只解析我正在采取的代码的代码如下,但我不知道如何继续前进.

  #include <boost/spirit/include/qi.hpp>
  #include <boost/spirit/include/support_line_pos_iterator.hpp>

  namespace qi = boost::spirit::qi;
  typedef boost::spirit::line_pos_iterator<std::string::const_iterator> pos_iterator_t;

  template<typename Iterator=pos_iterator_t, typename Skipper=qi::space_type>
  struct ParseGrammar: public qi::grammar<Iterator, Skipper>
  {
        ParseGrammar():ParseGrammar::base_type(SourceCode)
        {
           using namespace qi;
           KeywordFunction = lit("function");
           KeywordVar    = lit("var");
           SemiColon     = lit(';');

           Identifier = lexeme [alpha >> *(alnum | '_')];
           VarAssignemnt = …
Run Code Online (Sandbox Code Playgroud)

c++ boost abstract-syntax-tree boost-spirit-qi

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

什么是BOOST的物业地图?

有人可以向像我这样的Boost初学者解释什么是属性地图是在Boost?在尝试使用BGL计算强连接组件时,我遇到了这个问题.我去了属性地图和图形模块的文档,但仍然不知道该怎么做.以此代码为例: - make_iterator_property_map函数在做什么? - 这段代码的含义是什么:get(vertex_index,G)?

#include <boost/config.hpp>
#include <vector>
#include <iostream>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>

int
main()
{
  using namespace boost;
  typedef adjacency_list < vecS, vecS, directedS > Graph;
  const int N = 6;
  Graph G(N);
  add_edge(0, 1, G);
  add_edge(1, 1, G);
  add_edge(1, 3, G);
  add_edge(1, 4, G);
  add_edge(3, 4, G);
  add_edge(3, 0, G);
  add_edge(4, 3, G);
  add_edge(5, 2, G);

  std::vector<int> c(N);
  int num = strong_components
    (G, make_iterator_property_map(c.begin(), get(vertex_index, G), c[0]));

  std::cout << "Total number of components: " << num …
Run Code Online (Sandbox Code Playgroud)

c++ boost boost-graph boost-property-map

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