pimpl(也称为编译器防火墙)习惯用于缩短编译时间,但代价是可读性和一点运行时性能.目前一个项目需要很长时间才能编译,如何衡量最佳的pimpl候选人?
我有使用pimpl的经验,将项目的编译时间从两小时缩短到十分钟,但我只是按照我的直觉做了这个:我推断出类头文件包括(1)很多源代码(2)复杂/模板类,是使用疙瘩成语的最佳人选.
是否有一个工具可以客观地指出哪些类是优秀的pimpl候选人?
作为前瞻性声明的重要使用者,我喜欢我的课程在破坏时完成.为了确保这一点,我将析构函数设为私有并成为朋友boost::checked_delete:
#include <boost/checked_delete.hpp>
struct MyClass
{
//MyClass's interface
private:
~MyClass() { /* something */ }
friend void boost::checked_delete<>(MyClass* x);
};
Run Code Online (Sandbox Code Playgroud)
在C++ 11中,std::default_delete还会检查销毁时的完整性.然而,我无法实现与上述相同的行为:
#include <memory>
struct MyClass
{
//MyClass's interface
private:
~MyClass() { /* something */ }
friend struct std::default_delete<MyClass>;
};
int main()
{
//const std::shared_ptr<MyClass> d {
// std::make_shared<MyClass>()
//}; //(1) Should compile?
const std::shared_ptr<MyClass> d(
new MyClass,std::default_delete<MyClass>()
); //(2) Does compile
}
Run Code Online (Sandbox Code Playgroud)
我想知道
std::make_shared是一件好事我正在使用GCC 4.8.0,我检查了-std = c ++ 11和-std = c …
我工作的一个R项目是与特拉维斯CI测试.当我在testthat本地运行测试时,所有测试都通过.当这些测试在Travis CI上运行时,一些测试失败了.
问题是我无法看到测试运行后出现的详细错误消息.
我确实看到了特拉维斯错误的"顶部":
ERROR
Running the tests in ‘tests/testthat.R’ failed.
Last 13 lines of output:
OK: 825 SKIPPED: 0 FAILED: 9
1. Error: one posterior is added (@test-add_posteriors.R#44)
2. Error: two posteriors are added (@test-add_posteriors.R#116)
3. Error: three posteriors are added, middle is deleted and added again (@test-add_posteriors.R#197)
4. Error: alignment_to_beast_posterior: basic (@test-alignment_to_beast_posterior.R#28)
5. Error: are_identical_posteriors: use from local simulation (@test-are_identical_posteriors.R#58)
6. Error: do_simulation: use (@test-do_simulation.R#22)
7. Error: do_test_simulations: create exact replicate (@test-do_test_simulations.R#9) …Run Code Online (Sandbox Code Playgroud)