diff options
Diffstat (limited to 'include/__tree')
-rw-r--r-- | include/__tree | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/include/__tree b/include/__tree index 2fbb479801c2..2161c6cb79d1 100644 --- a/include/__tree +++ b/include/__tree @@ -43,6 +43,10 @@ template <class _Key, class _Value> struct __value_type; #endif +template <class _Key, class _CP, class _Compare, + bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value> +class __map_value_compare; + template <class _Allocator> class __map_node_destructor; template <class _TreeIterator> class _LIBCPP_TEMPLATE_VIS __map_iterator; template <class _TreeIterator> class _LIBCPP_TEMPLATE_VIS __map_const_iterator; @@ -957,6 +961,25 @@ private: }; +#ifndef _LIBCPP_CXX03_LANG +template <class _Tp, class _Compare, class _Allocator> +struct __diagnose_tree_helper { + static constexpr bool __trigger_diagnostics() + _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Compare const&, _Tp const&, _Tp const&>::value, + "the specified comparator type does not provide a const call operator") + { return true; } +}; + +template <class _Key, class _Value, class _KeyComp, class _Alloc> +struct __diagnose_tree_helper< + __value_type<_Key, _Value>, + __map_value_compare<_Key, __value_type<_Key, _Value>, _KeyComp>, + _Alloc +> : __diagnose_tree_helper<_Key, _KeyComp, _Alloc> +{ +}; +#endif // !_LIBCPP_CXX03_LANG + template <class _Tp, class _Compare, class _Allocator> class __tree { @@ -1479,7 +1502,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) template <class _Tp, class _Compare, class _Allocator> __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a) : __begin_node_(__iter_pointer()), - __pair1_(__node_allocator(__a)), + __pair1_(__second_tag(), __node_allocator(__a)), __pair3_(0) { __begin_node() = __end_node(); @@ -1489,7 +1512,7 @@ template <class _Tp, class _Compare, class _Allocator> __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a) : __begin_node_(__iter_pointer()), - __pair1_(__node_allocator(__a)), + __pair1_(__second_tag(), __node_allocator(__a)), __pair3_(0, __comp) { __begin_node() = __end_node(); @@ -1646,7 +1669,7 @@ __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _Input template <class _Tp, class _Compare, class _Allocator> __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t) : __begin_node_(__iter_pointer()), - __pair1_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())), + __pair1_(__second_tag(), __node_traits::select_on_container_copy_construction(__t.__node_alloc())), __pair3_(0, __t.value_comp()) { __begin_node() = __end_node(); @@ -1676,7 +1699,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) template <class _Tp, class _Compare, class _Allocator> __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a) - : __pair1_(__node_allocator(__a)), + : __pair1_(__second_tag(), __node_allocator(__a)), __pair3_(0, _VSTD::move(__t.value_comp())) { if (__a == __t.__alloc()) @@ -1789,7 +1812,11 @@ __tree<_Tp, _Compare, _Allocator>::~__tree() { static_assert((is_copy_constructible<value_compare>::value), "Comparator must be copy-constructible."); - destroy(__root()); +#ifndef _LIBCPP_CXX03_LANG + static_assert((__diagnose_tree_helper<_Tp, _Compare, _Allocator>:: + __trigger_diagnostics()), ""); +#endif + destroy(__root()); } template <class _Tp, class _Compare, class _Allocator> |