本文共 1764 字,大约阅读时间需要 5 分钟。
在1.60版本发布的5个月后,Boost发布了1.61版本,增加了一些新程序库,同时更新了许多程序库。
\\Boost 1.61包括4个新程序库:
\\std::vector host_vector(10000);\// 定义宿主机内容向量\// 获取默认设备,并且设置上下文\compute::device device = compute::system::default_device();\compute::context context(device);\compute::command_queue queue(context, device);\// 在设备上创建向量\compute::vector device_vector(host_vector.size(), context);\// 将数据从宿主机传输到设备上\compute::copy(\ host_vector.begin(), host_vector.end(), device_vector.begin(), queue\);\// 就地计算每个元素的平方根\compute::transform(\ device_vector.begin(),\ device_vector.end(),\ device_vector.begin(),\ compute::sqrt(),\ queue\);\// 将数据复制回宿主机\compute::copy(\ device_vector.begin(), device_vector.end(), host_vector.begin(), queue\);\\
// 持有指向插件变量指针的变量\boost::shared_ptr plugin;\plugin = dll::import(\ full_path_to_library,\ name_of_symbol_to_import,\ dll::load_mode::append_decorations\);\\
DLL也支持动态链接库的引用计数,以更好的控制已加载插件的生命周期、在插件卸载时执行回调函数和其他一些功能。
\\前文提到过,Boost 1.61也更新了许多现有程序库,包括(多倍精度数值库)、(含无效值容器库)、(几何库)、(容器库)等等。
\\查看英文原文:
\\感谢对本文的审校。
\\给InfoQ中文站投稿或者参与内容翻译工作,请邮件至。也欢迎大家通过新浪微博(,),微信(微信号:)关注我们。
转载地址:http://gfmdl.baihongyu.com/