为什么Boost的`bcp smart_ptr dir/`复制了6MB的源代码?

发布于 2024-09-14 08:05:37 字数 1142 浏览 10 评论 0原文

因此,我想将智能指针从 boost 中分离出来,以便在我的项目中使用,并指导我使用 bcp 实用程序。

今天我编译了它并执行了bcp smart_ptr to_copy_to_my_project/

结果:to_copy_to_my_project/ 目录中有 6MB 的代码。

你在开玩笑吧?我不想仅仅为了使用智能指针而将 6MB 的头文件添加到我的 100KB 项目中。

例如,它复制以下 win32 内容(我在 Linux 上):

Copying file: boost/thread/win32/basic_timed_mutex.hpp
Copying file: boost/thread/win32/condition_variable.hpp
Copying file: boost/thread/win32/interlocked_read.hpp

当我在 Linux 上时,为什么它会使用 smart_ptr 复制 win32 内容?

另外:

Copying file: boost/mpl/aux_/preprocessed/msvc60/advance_backward.hpp
...
Copying file: boost/mpl/aux_/preprocessed/msvc70/advance_backward.hpp
...
Copying file: boost/mpl/aux_/preprocessed/mwcw/advance_backward.hpp

并且:

Copying file: boost/date_time/adjust_functors.hpp

为什么 smart_ptr 依赖于 date_time?

另外,它复制的所有这些测试又如何:

Copying file: libs/smart_ptr/test/allocate_shared_esft_test.cpp
...

我不需要任何一个!我只需要 smart_ptr!

我做错了什么吗?为什么它只是为了智能指针而复制 6MB 的代码,而我预计是 10KB 或 20KB...

谢谢,Boda Cydo。

So I wanted to separate out just the smart pointers from boost to use in my project and I was guided to use bcp utility.

Today I got it compiled and did bcp smart_ptr to_copy_to_my_project/.

The result: 6MB of code in to_copy_to_my_project/ directory.

Are you kidding me? I don't want to add 6MB of header files to my 100KB project just to use smart pointers.

For example, it copies the following win32 stuff (I am on Linux):

Copying file: boost/thread/win32/basic_timed_mutex.hpp
Copying file: boost/thread/win32/condition_variable.hpp
Copying file: boost/thread/win32/interlocked_read.hpp

Why would it copy win32 stuff with smart_ptr when I am on Linux?

Also:

Copying file: boost/mpl/aux_/preprocessed/msvc60/advance_backward.hpp
...
Copying file: boost/mpl/aux_/preprocessed/msvc70/advance_backward.hpp
...
Copying file: boost/mpl/aux_/preprocessed/mwcw/advance_backward.hpp

And:

Copying file: boost/date_time/adjust_functors.hpp

Why does smart_ptr depend on date_time?

Also what about all these tests that it copied over:

Copying file: libs/smart_ptr/test/allocate_shared_esft_test.cpp
...

I don't need any of it! I just need smart_ptr!

Did I do something wrong? Why did it copy 6MB of code just for the smart pointers, which I would expect to be 10KB or 20KB...

Thanks, Boda Cydo.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

撩心不撩汉 2024-09-21 08:05:37

如果您想要的只是 smart_ptr 并且您对 #define'ing BOOST_SP_USE_QUICK_ALLOCATOR(默认情况下未定义)不感兴趣,您只需需要:

boost/assert.hpp
boost/checked_delete.hpp
boost/config.hpp
boost/config/compiler/*
boost/config/no_tr1/functional.hpp
boost/config/no_tr1/memory.hpp
boost/config/no_tr1/utility.hpp
boost/config/platform/*
boost/config/posix_features.hpp
boost/config/select_compiler_config.hpp
boost/config/select_platform_config.hpp
boost/config/select_stdlib_config.hpp
boost/config/stdlib/*
boost/config/suffix.hpp
boost/config/user.hpp
boost/current_function.hpp
boost/detail/interlocked.hpp
boost/detail/sp_typeinfo.hpp
boost/detail/workaround.hpp
boost/enable_shared_from_this.hpp
boost/exception/detail/attribute_noreturn.hpp
boost/exception/exception.hpp
boost/memory_order.hpp
boost/non_type.hpp
boost/shared_ptr.hpp
boost/smart_ptr/*
boost/throw_exception.hpp
boost/type.hpp

这达到了 365k,大部分代码实际上在 boost/smart_ptr 中。 boost/config 中还有很多代码。如果您知道目标平台,则可以减少 boost/config/compilerboost/config/platformboost/config/stdlib< /代码>。那么绝大多数代码将位于 boost/smart_ptr 中。

If all you want is smart_ptr and you're not interested in #define'ing BOOST_SP_USE_QUICK_ALLOCATOR (which is not defined by default), you only need:

boost/assert.hpp
boost/checked_delete.hpp
boost/config.hpp
boost/config/compiler/*
boost/config/no_tr1/functional.hpp
boost/config/no_tr1/memory.hpp
boost/config/no_tr1/utility.hpp
boost/config/platform/*
boost/config/posix_features.hpp
boost/config/select_compiler_config.hpp
boost/config/select_platform_config.hpp
boost/config/select_stdlib_config.hpp
boost/config/stdlib/*
boost/config/suffix.hpp
boost/config/user.hpp
boost/current_function.hpp
boost/detail/interlocked.hpp
boost/detail/sp_typeinfo.hpp
boost/detail/workaround.hpp
boost/enable_shared_from_this.hpp
boost/exception/detail/attribute_noreturn.hpp
boost/exception/exception.hpp
boost/memory_order.hpp
boost/non_type.hpp
boost/shared_ptr.hpp
boost/smart_ptr/*
boost/throw_exception.hpp
boost/type.hpp

This comes to 365k, with the bulk of the code actually in boost/smart_ptr. There is still a lot of code in boost/config. If you know what platforms you're targeting, you could pare down boost/config/compiler, boost/config/platform, and boost/config/stdlib. Then the vast majority of the code would be in boost/smart_ptr.

若有似无的小暗淡 2024-09-21 08:05:37

您可以只使用 stl 的共享指针:std::tr1::shared_ptr,从所有意图和目的来看,“是”boost::shared_ptr

You could just use the stl's shared pointer: std::tr1::shared_ptr, which for all intents and purposes "is" boost::shared_ptr.

千纸鹤带着心事 2024-09-21 08:05:37

我怀疑您可以删除 test 和 win32 文件夹 - 它们可能仅在测试时或在该平台上包含。我无法谈论大多数头文件,但我知道 smart_ptr 做了很多疯狂的事情,以便您可以将 boost::shared_ptr;进入 boost::shared_ptr,这是大多数模板无法做到的。如果您想要一个只适合几个文件的计数指针,那么编写一个并不难,但它不会像 boost 那样好。

既然你说你在 Linux 上,为什么不直接将 boost 列为依赖项呢?

I suspect that you could delete the test and win32 folders--they are probably only included when testing or on that platform. I can't speak to most of the header files, but I know smart_ptr does lots of crazy stuff so that you can convert boost::shared_ptr<Foo> into boost::shared_ptr<const Foo>, which most templates can't do. If you'd like a counting pointer that fits in only a few files, it's not hard to write one, but it won't be as nice as boost.

Since you say you're on Linux, why not just list boost as a dependency?

粉红×色少女 2024-09-21 08:05:37

原因是 boost 支持无数的平台和编译器,并且 boost 模块可以自由地使用其他 boost 模块。尽管大部分内容都会被 #ifdef:ed 掉,但 bcp 还不够聪明,无法做到这一点。

我遇到了类似的问题,所以我理解你的担忧。我尝试在没有平台设置的情况下运行预处理器,然后代码变得明显更小。

最后我们将编译器升级到支持C++ tr1的版本并使用std::tr1::shared_ptr。

有人可能会说 6Megs 对于行业标准智能指针来说只是一个很小的代价,但并非所有开发人员/架构师都有同样的感觉,而且由于我不是专制者,但我必须遵循团队的决定。

The reason being that boost supports a myriad platforms and compilers and boost modules uses other boost modules liberally. Even though most of it will be #ifdef:ed away bcp isn't smart enough to do that.

I had a similar issue so I understand your concern. I tried running the preprocessor with out platform settings then the code became significantly smaller.

In the end though we upgraded the compiler to the version that supports C++ tr1 and use std::tr1::shared_ptr.

One might argue that 6Megs are a small price to pay for industry standard smart pointers however not all developers/architects feel the same way and since I'm no despot yet I had to go with what the team decides.

战皆罪 2024-09-21 08:05:37

如果你这样做,bcp 的复制量会少很多

bcp shared_ptr.hpp to_copy_to_my_project/.

,我同意,它看起来仍然太多了。

bcp will copy a lot less if you do

bcp shared_ptr.hpp to_copy_to_my_project/.

It still seems like way too much, I agree.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文