Add element_type to nodes, so that pointer_traits will work

Might be better to change the template signature of iterators, but that would
be a disruptive change to make at the moment.
This commit is contained in:
Daniel James
2018-01-26 17:43:06 +00:00
parent ea599a66b7
commit 66533ace80
Notes: Daniel James 2018-02-25 14:20:03 +00:00
Added `element_type` to iterators, not nodes
2 changed files with 77 additions and 0 deletions

View File

@ -2260,6 +2260,7 @@ namespace boost {
std::size_t bucket_count_;
public:
typedef typename Node::value_type element_type;
typedef typename Node::value_type value_type;
typedef value_type* pointer;
typedef value_type& reference;
@ -2316,6 +2317,7 @@ namespace boost {
std::size_t bucket_count_;
public:
typedef typename Node::value_type const element_type;
typedef typename Node::value_type value_type;
typedef value_type const* pointer;
typedef value_type const& reference;
@ -2384,6 +2386,7 @@ namespace boost {
node_pointer node_;
public:
typedef typename Node::value_type element_type;
typedef typename Node::value_type value_type;
typedef value_type* pointer;
typedef value_type& reference;
@ -2439,6 +2442,7 @@ namespace boost {
node_pointer node_;
public:
typedef typename Node::value_type const element_type;
typedef typename Node::value_type value_type;
typedef value_type const* pointer;
typedef value_type const& reference;

View File

@ -18,6 +18,7 @@
#include "../helpers/check_return_type.hpp"
#include <boost/limits.hpp>
#include <boost/core/pointer_traits.hpp>
#include <boost/predef.h>
#include <boost/static_assert.hpp>
#include <boost/type_traits/cv_traits.hpp>
@ -280,6 +281,42 @@ template <class X, class Key> void unordered_set_test(X& r, Key const&)
BOOST_STATIC_ASSERT(
(boost::is_same<value_type const*, const_local_iterator_pointer>::value));
// pointer_traits<iterator>
BOOST_STATIC_ASSERT((boost::is_same<iterator,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<iterator>::pointer>::value));
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<iterator>::element_type>::value));
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<iterator>::difference_type>::value));
// pointer_traits<const_iterator>
BOOST_STATIC_ASSERT((boost::is_same<const_iterator,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<const_iterator>::pointer>::value));
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<const_iterator>::element_type>::value));
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<const_iterator>::difference_type>::value));
// pointer_traits<local_iterator>
BOOST_STATIC_ASSERT((boost::is_same<local_iterator,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<local_iterator>::pointer>::value));
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<local_iterator>::element_type>::value));
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<local_iterator>::difference_type>::value));
// pointer_traits<const_local_iterator>
BOOST_STATIC_ASSERT((boost::is_same<const_local_iterator,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<const_local_iterator>::pointer>::value));
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<const_local_iterator>::element_type>::value));
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<const_local_iterator>::difference_type>::value));
typedef BOOST_DEDUCED_TYPENAME X::node_type node_type;
typedef BOOST_DEDUCED_TYPENAME node_type::value_type node_value_type;
BOOST_STATIC_ASSERT((boost::is_same<value_type, node_value_type>::value));
@ -325,6 +362,42 @@ void unordered_map_test(X& r, Key const& k, T const& v)
BOOST_STATIC_ASSERT(
(boost::is_same<value_type const*, const_local_iterator_pointer>::value));
// pointer_traits<iterator>
BOOST_STATIC_ASSERT((boost::is_same<iterator,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<iterator>::pointer>::value));
BOOST_STATIC_ASSERT((boost::is_same<value_type,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<iterator>::element_type>::value));
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<iterator>::difference_type>::value));
// pointer_traits<const_iterator>
BOOST_STATIC_ASSERT((boost::is_same<const_iterator,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<const_iterator>::pointer>::value));
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<const_iterator>::element_type>::value));
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<const_iterator>::difference_type>::value));
// pointer_traits<local_iterator>
BOOST_STATIC_ASSERT((boost::is_same<local_iterator,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<local_iterator>::pointer>::value));
BOOST_STATIC_ASSERT((boost::is_same<value_type,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<local_iterator>::element_type>::value));
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<local_iterator>::difference_type>::value));
// pointer_traits<const_local_iterator>
BOOST_STATIC_ASSERT((boost::is_same<const_local_iterator,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<const_local_iterator>::pointer>::value));
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<const_local_iterator>::element_type>::value));
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
BOOST_DEDUCED_TYPENAME boost::pointer_traits<const_local_iterator>::difference_type>::value));
typedef BOOST_DEDUCED_TYPENAME X::node_type node_type;
typedef BOOST_DEDUCED_TYPENAME node_type::key_type node_key_type;
typedef BOOST_DEDUCED_TYPENAME node_type::mapped_type node_mapped_type;