Index: include/__split_buffer =================================================================== --- include/__split_buffer +++ include/__split_buffer @@ -276,7 +276,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) { while (__begin_ != __new_begin) - __alloc_traits::destroy(__alloc(), __to_raw_pointer(__begin_++)); + __alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(__begin_++)); } template @@ -293,7 +293,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT { while (__new_last != __end_) - __alloc_traits::destroy(__alloc(), __to_raw_pointer(--__end_)); + __alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_)); } template Index: include/memory =================================================================== --- include/memory +++ include/memory @@ -1346,9 +1346,9 @@ struct __has_construct : integral_constant(), - declval<_Pointer>(), - declval<_Args>()...)), + decltype(_VSTD::__has_construct_test(declval<_Alloc>(), + declval<_Pointer>(), + declval<_Args>()...)), true_type>::value> { }; @@ -1367,8 +1367,8 @@ struct __has_destroy : integral_constant(), - declval<_Pointer>())), + decltype(_VSTD::__has_destroy_test(declval<_Alloc>(), + declval<_Pointer>())), true_type>::value> { }; @@ -1387,7 +1387,7 @@ struct __has_max_size : integral_constant())), + decltype(_VSTD::__has_max_size_test(declval<_Alloc&>())), true_type>::value> { }; @@ -1406,7 +1406,7 @@ struct __has_select_on_container_copy_construction : integral_constant())), + decltype(_VSTD::__has_select_on_container_copy_construction_test(declval<_Alloc&>())), true_type>::value> { }; @@ -1547,7 +1547,7 @@ template _LIBCPP_INLINE_VISIBILITY static void destroy(allocator_type& __a, _Tp* __p) - {__destroy(__has_destroy(), __a, __p);} + {__destroy(_VSTD::__has_destroy(), __a, __p);} _LIBCPP_INLINE_VISIBILITY static size_type max_size(const allocator_type& __a) _NOEXCEPT Index: test/std/containers/containers.general/construct_destruct.pass.cpp =================================================================== --- /dev/null +++ test/std/containers/containers.general/construct_destruct.pass.cpp @@ -0,0 +1,128 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Holder is a do-nothing wrapper around a value of the given type. +// +// Since unqualified name lookup and operator overload lookup participate in +// ADL, the dependent type ns::T contributes to the overload set considered by +// ADL. In other words, ADL will consider all associated namespaces: this +// includes not only N, but also any inline friend functions declared by ns::T. +// +// The purpose of this test is to ensure that simply constructing or destroying +// a container does not invoke ADL which would be problematic for unknown types. +// By using the type 'Holder *' as a container value, we can avoid the +// obvious problems with unknown types: a pointer is trivial, and its size is +// known. However, any ADL which includes ns::T as an associated namesapce will +// fail. +// +// For example: +// +// namespace ns { +// class T { +// // 13.5.7 [over.inc]: +// friend std::list::const_iterator +// operator++(std::list::const_iterator it) { +// return /* ... */; +// } +// }; +// } +// +// The C++ standard stipulates that some functions, such as std::advance, use +// overloaded operators (in C++14: 24.4.4 [iterator.operations]). The +// implication is that calls to such a function are dependent on knowing the +// overload set of operators in all associated namespaces; under ADL, this +// includes the private friend function in the example above. +// +// However, for some operations, such as construction and destruction, no such +// ADL is required. This can be important, for example, when using the Pimpl +// pattern: +// +// // Defined in a header file: +// class InterfaceList { +// // Defined in a .cpp file: +// class Impl; +// vector impls; +// public: +// ~InterfaceList(); +// }; +// +template +class Holder { T value; }; + +namespace ns { class Fwd; } + +// TestSequencePtr and TestMappingPtr ensure that a given container type can be +// default-constructed and destroyed with an incomplete value pointer type. +template