0

在 VS2010 和 VS2012 头文件版本之间,智能指针(shared_ptr、unique_ptr 和weakptr)的声明似乎有所不同。

据我了解,例如 shared_ptr 现在(通过 C++11)是 std 命名空间的一部分。对于兼容性问题,它是否仍然是 tr1 命名空间的一部分?如果是这样,这是如何实现的?

谢谢

4

1 回答 1

1

在标题<memory>中,他们定义了tr1这样的命名空间:

namespace tr1 { // TR1 additions
using _STD allocate_shared;
using _STD bad_weak_ptr;
using _STD const_pointer_cast;
using _STD dynamic_pointer_cast;
using _STD enable_shared_from_this;
using _STD get_deleter;
using _STD make_shared;
using _STD shared_ptr;
using _STD static_pointer_cast;
using _STD swap;
using _STD weak_ptr;
}   // namespace tr1

_STD在 yvals.h 中定义为

#if defined(__cplusplus)
 #define _STD_BEGIN namespace std {
 #define _STD_END       }
 #define _STD   ::std::
于 2013-07-25T11:24:12.580 回答