Tag: boost

为什么ucontext有这么高的开销?

Boost v1.59中Boost.Context的文档报告了以下性能比较结果: +———-+———————-+——————-+——————-+—————-+ | Platform | ucontext_t | fcontext_t | execution_context | windows fibers | +———-+———————-+——————-+——————-+—————-+ | i386 | 708 ns / 754 cycles | 37 ns / 37 cycles | ns / cycles | ns / cycles | | x86_64 | 547 ns / 1433 cycles | 8 ns / 23 cycles | 16 […]

无法构建提升

我已经能够使用以下命令在Windows Vista上编译boost: bootstrap.bat bjam.exe –with-filesystem –with-thread –toolset=msvc 但是,当我在Windows 7上发出相同的命令时,我得到了这个: ‘failed to write output file ‘bin.v2\libs\thread\build\msvc-8.0\release\link-static\threading-multi\libboost_thread-vc80-mt-1_48.lib.rsp’!’ 我究竟做错了什么?

g ++ – 4.6.real:错误:无法识别的选项’-R’

我正在尝试使用此configure命令从源代码编译phpcompiler 。 ./configure –prefix=/opt/phc-0.3.0.1/ –with-php=/opt/php-5.3.17/ 配置错误是, checking for exit in -lboost_regex-mt… no checking for exit in -lboost_regex-mt… (cached) no checking for exit in -lboost_regex… no checking for exit in -lboost_regex… (cached) no checking for exit in -lboost_regex… (cached) no configure: error: Could not link against boost_regex 这完全错了,因为我安装了boost和boost_regex软件包。 libs和头文件。 然后我在config.log文件中挖了这个 configure:17053: g++ -o conftest -g -O2 […]

在C代码中使用boost :: bind(),它会起作用吗?

我可以在C代码中使用boost::bind(mycallback, this, _1, _2)吗? 更新 简短的回答是不 ,boost bind不会返回一个函数指针,它可以在C代码中调用,但是一个函子 (带有overloaded ()运算符的C ++对象)请参见下面的答案。

C / C ++中的自展开宏循环

我目前正在开展一个项目,每个周期都很重要。 在分析我的应用程序时,我发现一些内部循环的开销非常高,因为它们只包含一些机器指令。 此外,这些循环中的迭代次数在编译时是已知的。 所以我认为不是手动展开带有复制和粘贴的循环,而是可以使用宏在编译时展开循环,以便以后可以轻松修改它。 我的形象是这样的: #define LOOP_N_TIMES(N, CODE) 这样我就可以替换for (int i = 0; i < N, ++i) { do_stuff(); } 用: #define INNER_LOOP_COUNT 4 LOOP_N_TIMES(INNER_LOOP_COUNT, do_stuff();) 它将自己展开: do_stuff(); do_stuff(); do_stuff(); do_stuff(); 由于C预处理器在大多数时间对我来说仍然是一个谜,我不知道如何实现这一点,但我知道它必须是可能的,因为Boost似乎有一个BOOST_PP_REPEAT宏。 不幸的是我不能在这个项目中使用Boost。