What are differences between std, tr1 and boost (as namespaces and/or libraries)?(std、tr1 和 boost(作为命名空间和/或库)之间有什么区别?)
问题描述
我最初认为它们都是一样的,但结果证明是错误的.那么谁能简单解释一下这三者之间的区别?例如:
std::bind
(最新的,下一代C++)std::tr1::bind
(旧的,C++ std 的扩展)boost::bind
(完全独立的库)
或std::shared_ptr
、std::tr1::shared_ptr
和boost::shared_ptr
、...等>
更新
bind
、shared_ptr
是有助于澄清我的问题的示例.我的目的是了解这三个命名空间之间的一般差异.有几个库存在于所有三个命名空间中,显然 bind
和 shared_ptr
就是一个例子.
我应该坚持使用哪些命名空间?我个人更喜欢 std::
中的库,因为它将成为 C++ ( C++0x ) 的下一个标准.
1 - std::bind
是它的标准名称.这将是您用于 C++11 兼容库的名称.所有标准化C++库的列表.
2 - std::tr1::bind
是 C++ 技术报告 1 命名空间.在 C++03 和 C++11 之间有 C++ 技术报告 1,其中提出了额外的库和增强功能.其中大部分在当时已经存在于 Boost 中,其中一些库更改被 C++11 标准采用,例如
和
(其中包含 std::bind
).std::tr1
命名空间用于区分处于工作中状态的库,而不是在 std
命名空间中标准化的所有内容.
3 - boost::bind
用于 boost
命名空间中的 bind
,如果您使用的是 Boost 库.Boost 包含的内容远不止 TR1 中的内容和 C++11 标准库中的内容.所有 截至 1.52.0 的 Boost 库列表>
TR1 中的大部分内容已经标准化并位于 C++11 std
命名空间中,并且 C++11 包含比 TR1 中提到的更多的库,这些库改编自 Boost 结构,例如
中定义的线程支持.
定义您可以使用的内容以及您现在可以使用的命名空间的部分内容取决于您的编译器.我不记得了,但我认为最近的 GCC-g++ 实现已经开始为新的 C++11 库使用 std
命名空间,但可能需要不同的编译器标志来激活它.不过,它们仍将支持 std::tr1
命名空间.Visual C++ 2010 将以前在 std::tr1
中的内容移动到普通的 std
命名空间中,但 Visual C++ 2008 仍然使用 std::tr1
.
I initially thought they're all the same, but it turned out to be wrong. So can anyone briefly explain the differences between these three? For example:
std::bind
( newest one, next generation of C++ )std::tr1::bind
( old, extension of C++ std )boost::bind
( completely separate library )
or std::shared_ptr
, std::tr1::shared_ptr
, and boost::shared_ptr
, ...etc
Update
bind
, shared_ptr
are examples that help to clarify my question. My intention was to understand the general differences between those three namespaces. There are several libraries that exist in all three namespaces, and apparently bind
is one example, as well as shared_ptr
.
What namespaces should I stick with? I personally prefer library from std::
since it will be the next standard of C++ ( C++0x ).
1 - std::bind
is the the standard name for it. This will be the name you use for C++11 compliant libraries. List of all libraries in standardized C++.
2 - std::tr1::bind
is C++ Technical Report 1 namespace. Between C++03 and C++11 there was the C++ Technical Report 1, which proposed additional libraries and enhancements. Most of these already existed in Boost at the time, and some of these library changes were adopted in the C++11 standard, like <regex>
and <functional>
(which contains std::bind
). The std::tr1
namespace was used to differentiate the libraries in their work-in-progress state, as opposed to everything standardized in the std
namespace.
3 - boost::bind
is for bind
in the boost
namespace, if you are using the Boost library. Boost encompasses much more than what is in TR1 and what i in C++11's std library. List of all libraries in Boost as of 1.52.0
Most of what was in TR1 has been standardized and is in the C++11 std
namespace, and C++11 contains more libraries than mentioned in TR1 that were adapted from Boost constructs, like threading support defined in <thread>
.
Part of what defines what you can use and which namespace you can use now depends on your compiler. I don't recall, but I think the more recent GCC-g++ implementations have started using std
namespaces for the new C++11 libraries, but might require a different compiler flag to activate that. They will still support the std::tr1
namespace though. Visual C++ 2010 moved what was previously in std::tr1
into the normal std
namespace, but Visual C++ 2008 still used std::tr1
.
这篇关于std、tr1 和 boost(作为命名空间和/或库)之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:std、tr1 和 boost(作为命名空间和/或库)之间有什么区别?
基础教程推荐
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 使用从字符串中提取的参数调用函数 2022-01-01
- 从 std::cin 读取密码 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01