小编sil*_*ngb的帖子

boost :: property_tree :: ptree的内存开销是多少

我发现boost :: property_tree :: ptree有很大的内存开销.我的估计是空的ptree大约是150个字节,并且放在ptree中的任何条目至少会增加150个字节.这使得我们无法使用包含数千个条目的树.

估计我的估计?有没有办法保持低开销?

memory tree boost properties ptree

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

使用std :: async和模板函数

我怎样才能或者可以将模板函数传递给异步?

这是代码:

//main.cpp
#include <future>
#include <vector>
#include <iostream>
#include <numeric>

int
main
    ()
{      
    std::vector<double> v(16,1);

    auto r0 =  std::async(std::launch::async,std::accumulate,v.begin(),v.end(),double(0.0));

    std::cout << r0.get() << std::endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

以下是错误消息:

                                                                               ^
a.cpp:13:88: note: candidates are:
In file included from a.cpp:1:0:
/usr/include/c++/4.8/future:1523:5: note: template std::future::type> std::async(std::launch, _Fn&&, _Args&& ...)
     async(launch __policy, _Fn&& __fn, _Args&&... __args)
     ^
/usr/include/c++/4.8/future:1523:5: note:   template argument deduction/substitution failed:
a.cpp:13:88: note:   couldn't deduce template parameter ‘_Fn’
   auto r0 = std::async(std::launch::async,std::accumulate,v.begin(),v.end(),double(0.0));
                                                                                        ^
In file included from a.cpp:1:0:
/usr/include/c++/4.8/future:1543:5: note: …

c++ algorithm templates c++11 stdasync

6
推荐指数
2
解决办法
1534
查看次数

标签 统计

algorithm ×1

boost ×1

c++ ×1

c++11 ×1

memory ×1

properties ×1

ptree ×1

stdasync ×1

templates ×1

tree ×1