boost bcp——namespace到底做了什么?

What does boost bcp --namespace really do?

本文关键字:什么 bcp namespace boost      更新时间:2023-10-16

我的印象是,带有名称空间选项的boost bcp意味着为任何列出的模块重命名包含和定义。在运行该工具并检查输出后,它似乎没有这样做。如果它们仍然是#include <boost/*>,并且期望最终用户的#include <boost/*>不会引起版本冲突,我该如何重新分发它们?它只是用名称空间闭包包装这些吗?

我使用了以下bcp命令:

.boost_1_53_0distbinbcp.exe --boost=boost_1_53_0 --namespace=myboost --namespace-alias smart_ptr filesystem array.hpp container move ptr_container algorithm/string.hpp tokenizer.hpp thread chrono atomic foreach.hpp build myboost

快速grep文件生成:

[boost]grep -e "boost/" algorithmstring.hpp
grep -e "boost/" algorithmstring.hpp
#include <boost/algorithm/string/std_containers_traits.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/find.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/erase.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/find_iterator.hpp>

我很确定这是带有名称空间选项的bcp工具的用例,然而,我显然误解了一些常见的c++概念/用法,对吗?或者,也许是我错误地使用了这个工具?

提前感谢您的建议。

BCP——namespace=myboost——namespace-alias regex config build/foo

复制完整的regex库(在libs/regex中)加上配置库(libs/config)和构建系统(tools/build)到/foo,包括所有依赖项。还将boost命名空间重命名为myboost,并将二进制库的文件名更改为以前缀"myboost"而不是"boost"开头。——namespace-alias选项使命名空间boost成为新名称的别名。

只有二进制文件将被重命名(libboost_regex.so将是libmyboost_regex.so),而不是头文件。另外,命名空间boost将被myboost取代(boost将成为myboost的别名)。

如其名称所示,它重命名命名空间和库文件(即。dll和。libs),但不重命名头文件所在的目录,因此不重命名include。

Boost库通常位于namespace boost中。使用bcp将该名称空间更改为myboost。例如,下面的代码是有效的:
#include <boost/sharedptr.hpp> //header directories haven't changed
myboost::shared_ptr<int> pi = myboost::make_shared<int>(5); //but the namespace has

多亏了--namespace-alias,您可以继续使用命名空间boost,因为boost已经成为myboost的别名:

boost::shared_ptr<int> pi; //ok, this is in fact a myboost::shared_ptr

参见文档中的示例:http://www.boost.org/doc/libs/1_53_0/tools/bcp/doc/html/index.html