summaryrefslogtreecommitdiff
path: root/boost/container/detail/flat_tree.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/container/detail/flat_tree.hpp')
-rw-r--r--boost/container/detail/flat_tree.hpp73
1 files changed, 41 insertions, 32 deletions
diff --git a/boost/container/detail/flat_tree.hpp b/boost/container/detail/flat_tree.hpp
index e9cbe38894..e131cf1f55 100644
--- a/boost/container/detail/flat_tree.hpp
+++ b/boost/container/detail/flat_tree.hpp
@@ -921,11 +921,11 @@ class flat_tree
std::pair<iterator, bool> emplace_unique(BOOST_FWD_REF(Args)... args)
{
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;
- value_type &val = *static_cast<value_type *>(static_cast<void *>(v.data));
+ value_type *pval = reinterpret_cast<value_type *>(v.data);
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();
- stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... );
- value_destructor<stored_allocator_type, value_type> d(a, val);
- return this->insert_unique(::boost::move(val));
+ stored_allocator_traits::construct(a, pval, ::boost::forward<Args>(args)... );
+ value_destructor<stored_allocator_type, value_type> d(a, *pval);
+ return this->insert_unique(::boost::move(*pval));
}
template <class... Args>
@@ -933,22 +933,22 @@ class flat_tree
{
//hint checked in insert_unique
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;
- value_type &val = *static_cast<value_type *>(static_cast<void *>(v.data));
+ value_type *pval = reinterpret_cast<value_type *>(v.data);
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();
- stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... );
- value_destructor<stored_allocator_type, value_type> d(a, val);
- return this->insert_unique(hint, ::boost::move(val));
+ stored_allocator_traits::construct(a, pval, ::boost::forward<Args>(args)... );
+ value_destructor<stored_allocator_type, value_type> d(a, *pval);
+ return this->insert_unique(hint, ::boost::move(*pval));
}
template <class... Args>
iterator emplace_equal(BOOST_FWD_REF(Args)... args)
{
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;
- value_type &val = *static_cast<value_type *>(static_cast<void *>(v.data));
+ value_type *pval = reinterpret_cast<value_type *>(v.data);
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();
- stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... );
- value_destructor<stored_allocator_type, value_type> d(a, val);
- return this->insert_equal(::boost::move(val));
+ stored_allocator_traits::construct(a, pval, ::boost::forward<Args>(args)... );
+ value_destructor<stored_allocator_type, value_type> d(a, *pval);
+ return this->insert_equal(::boost::move(*pval));
}
template <class... Args>
@@ -956,11 +956,11 @@ class flat_tree
{
//hint checked in insert_equal
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;
- value_type &val = *static_cast<value_type *>(static_cast<void *>(v.data));
+ value_type *pval = reinterpret_cast<value_type *>(v.data);
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();
- stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... );
- value_destructor<stored_allocator_type, value_type> d(a, val);
- return this->insert_equal(hint, ::boost::move(val));
+ stored_allocator_traits::construct(a, pval, ::boost::forward<Args>(args)... );
+ value_destructor<stored_allocator_type, value_type> d(a, *pval);
+ return this->insert_equal(hint, ::boost::move(*pval));
}
template <class KeyType, class... Args>
@@ -993,44 +993,44 @@ class flat_tree
std::pair<iterator, bool> emplace_unique(BOOST_MOVE_UREF##N)\
{\
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;\
- value_type &val = *static_cast<value_type *>(static_cast<void *>(v.data));\
+ value_type *pval = reinterpret_cast<value_type *>(v.data);\
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();\
- stored_allocator_traits::construct(a, &val BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
- value_destructor<stored_allocator_type, value_type> d(a, val);\
- return this->insert_unique(::boost::move(val));\
+ stored_allocator_traits::construct(a, pval BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
+ value_destructor<stored_allocator_type, value_type> d(a, *pval);\
+ return this->insert_unique(::boost::move(*pval));\
}\
\
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
iterator emplace_hint_unique(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
{\
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;\
- value_type &val = *static_cast<value_type *>(static_cast<void *>(v.data));\
+ value_type *pval = reinterpret_cast<value_type *>(v.data);\
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();\
- stored_allocator_traits::construct(a, &val BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
- value_destructor<stored_allocator_type, value_type> d(a, val);\
- return this->insert_unique(hint, ::boost::move(val));\
+ stored_allocator_traits::construct(a, pval BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
+ value_destructor<stored_allocator_type, value_type> d(a, *pval);\
+ return this->insert_unique(hint, ::boost::move(*pval));\
}\
\
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
iterator emplace_equal(BOOST_MOVE_UREF##N)\
{\
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;\
- value_type &val = *static_cast<value_type *>(static_cast<void *>(v.data));\
+ value_type *pval = reinterpret_cast<value_type *>(v.data);\
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();\
- stored_allocator_traits::construct(a, &val BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
- value_destructor<stored_allocator_type, value_type> d(a, val);\
- return this->insert_equal(::boost::move(val));\
+ stored_allocator_traits::construct(a, pval BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
+ value_destructor<stored_allocator_type, value_type> d(a, *pval);\
+ return this->insert_equal(::boost::move(*pval));\
}\
\
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
iterator emplace_hint_equal(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
{\
typename aligned_storage <sizeof(value_type), alignment_of<value_type>::value>::type v;\
- value_type &val = *static_cast<value_type *>(static_cast<void *>(v.data));\
+ value_type *pval = reinterpret_cast<value_type *>(v.data);\
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();\
- stored_allocator_traits::construct(a, &val BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
- value_destructor<stored_allocator_type, value_type> d(a, val);\
- return this->insert_equal(hint, ::boost::move(val));\
+ stored_allocator_traits::construct(a, pval BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
+ value_destructor<stored_allocator_type, value_type> d(a, *pval);\
+ return this->insert_equal(hint, ::boost::move(*pval));\
}\
template <class KeyType BOOST_MOVE_I##N BOOST_MOVE_CLASS##N>\
BOOST_CONTAINER_FORCEINLINE std::pair<iterator, bool>\
@@ -1201,6 +1201,15 @@ class flat_tree
return n;
}
+ BOOST_CONTAINER_FORCEINLINE bool contains(const key_type& x) const
+ { return this->find(x) != this->cend(); }
+
+ template<typename K>
+ BOOST_CONTAINER_FORCEINLINE
+ typename dtl::enable_if_transparent<key_compare, K, bool>::type
+ contains(const K& x) const
+ { return this->find(x) != this->cend(); }
+
template<class C2>
BOOST_CONTAINER_FORCEINLINE void merge_unique(flat_tree<Value, KeyOfValue, C2, AllocatorOrContainer>& source)
{