From 8e34a1f6a75ee1e9f94614bc162c8c80cbffeece Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Mon, 27 Apr 2015 13:33:34 -0700 Subject: [PATCH] Tidy up aged container declarations --- .../detail/aged_container_iterator.h | 2 +- .../container/detail/aged_ordered_container.h | 83 ++++++++--------- .../detail/aged_unordered_container.h | 91 ++++++++++--------- 3 files changed, 89 insertions(+), 87 deletions(-) diff --git a/src/beast/beast/container/detail/aged_container_iterator.h b/src/beast/beast/container/detail/aged_container_iterator.h index f82cb401a..b849f4ade 100644 --- a/src/beast/beast/container/detail/aged_container_iterator.h +++ b/src/beast/beast/container/detail/aged_container_iterator.h @@ -49,7 +49,7 @@ class aged_container_iterator : public Base { public: - typedef typename Iterator::value_type::stashed::time_point time_point; + using time_point = typename Iterator::value_type::stashed::time_point; // Could be '= default', but Visual Studio 2013 chokes on it [Aug 2014] aged_container_iterator () diff --git a/src/beast/beast/container/detail/aged_ordered_container.h b/src/beast/beast/container/detail/aged_ordered_container.h index 398cd8aa3..73b88aade 100644 --- a/src/beast/beast/container/detail/aged_ordered_container.h +++ b/src/beast/beast/container/detail/aged_ordered_container.h @@ -125,8 +125,8 @@ private: // need to see the container declaration. struct stashed { - typedef typename aged_ordered_container::value_type value_type; - typedef typename aged_ordered_container::time_point time_point; + using value_type = typename aged_ordered_container::value_type; + using time_point = typename aged_ordered_container::time_point; }; element ( @@ -243,11 +243,10 @@ private: } }; - typedef typename boost::intrusive::make_list - >::type list_type; + using list_type = typename boost::intrusive::make_list >::type; - typedef typename std::conditional < + using cont_type = typename std::conditional < IsMulti, typename boost::intrusive::make_multiset @@ -255,10 +254,10 @@ private: typename boost::intrusive::make_set >::type - >::type cont_type; + >::type; - typedef typename std::allocator_traits < - Allocator>::template rebind_alloc ElementAllocator; + using ElementAllocator = typename std::allocator_traits < + Allocator>::template rebind_alloc ; using ElementAllocatorTraits = std::allocator_traits ; @@ -426,29 +425,29 @@ private: } public: - typedef Compare key_compare; - typedef typename std::conditional < + using key_compare = Compare; + using value_compare = typename std::conditional < IsMap, pair_value_compare, - Compare>::type value_compare; - typedef Allocator allocator_type; - typedef value_type& reference; - typedef value_type const& const_reference; - typedef typename std::allocator_traits < - Allocator>::pointer pointer; - typedef typename std::allocator_traits < - Allocator>::const_pointer const_pointer; + Compare>::type; + using allocator_type = Allocator; + using reference = value_type&; + using const_reference = value_type const&; + using pointer = typename std::allocator_traits < + Allocator>::pointer; + using const_pointer = typename std::allocator_traits < + Allocator>::const_pointer; - // A set (that is, !IsMap) iterator is aways const because the elements - // of a set are immutable. - typedef detail::aged_container_iterator iterator; - typedef detail::aged_container_iterator const_iterator; - typedef detail::aged_container_iterator reverse_iterator; - typedef detail::aged_container_iterator const_reverse_iterator; + // A set iterator (IsMap==false) is always const + // because the elements of a set are immutable. + using iterator = detail::aged_container_iterator< + ! IsMap, typename cont_type::iterator>; + using const_iterator = detail::aged_container_iterator< + true, typename cont_type::iterator>; + using reverse_iterator = detail::aged_container_iterator< + ! IsMap, typename cont_type::reverse_iterator>; + using const_reverse_iterator = detail::aged_container_iterator< + true, typename cont_type::reverse_iterator>; //-------------------------------------------------------------------------- // @@ -462,16 +461,16 @@ public: class chronological_t { public: - // A set (that is, !IsMap) iterator is aways const because the elements - // of a set are immutable. - typedef detail::aged_container_iterator iterator; - typedef detail::aged_container_iterator const_iterator; - typedef detail::aged_container_iterator reverse_iterator; - typedef detail::aged_container_iterator const_reverse_iterator; + // A set iterator (IsMap==false) is always const + // because the elements of a set are immutable. + using iterator = detail::aged_container_iterator< + ! IsMap, typename list_type::iterator>; + using const_iterator = detail::aged_container_iterator< + true, typename list_type::iterator>; + using reverse_iterator = detail::aged_container_iterator< + ! IsMap, typename list_type::reverse_iterator>; + using const_reverse_iterator = detail::aged_container_iterator< + true, typename list_type::reverse_iterator>; iterator begin () { @@ -569,6 +568,8 @@ public: // //-------------------------------------------------------------------------- + aged_ordered_container() = delete; + explicit aged_ordered_container (clock_type& clock); aged_ordered_container (clock_type& clock, @@ -1848,9 +1849,9 @@ operator== ( Key, OtherT, OtherDuration, Compare, OtherAllocator> const& other) const { - typedef aged_ordered_container Other; + OtherAllocator>; if (size() != other.size()) return false; std::equal_to eq; diff --git a/src/beast/beast/container/detail/aged_unordered_container.h b/src/beast/beast/container/detail/aged_unordered_container.h index bcfca25d3..0b7d178ad 100644 --- a/src/beast/beast/container/detail/aged_unordered_container.h +++ b/src/beast/beast/container/detail/aged_unordered_container.h @@ -123,8 +123,8 @@ private: // need to see the container declaration. struct stashed { - typedef typename aged_unordered_container::value_type value_type; - typedef typename aged_unordered_container::time_point time_point; + using value_type = typename aged_unordered_container::value_type; + using time_point = typename aged_unordered_container::time_point; }; element ( @@ -248,11 +248,10 @@ private: } }; - typedef typename boost::intrusive::make_list - >::type list_type; + using list_type = typename boost::intrusive::make_list >::type ; - typedef typename std::conditional < + using cont_type = typename std::conditional < IsMulti, typename boost::intrusive::make_unordered_multiset , @@ -266,18 +265,18 @@ private: boost::intrusive::equal , boost::intrusive::cache_begin >::type - >::type cont_type; + >::type; - typedef typename cont_type::bucket_type bucket_type; - typedef typename cont_type::bucket_traits bucket_traits; + using bucket_type = typename cont_type::bucket_type; + using bucket_traits = typename cont_type::bucket_traits; - typedef typename std::allocator_traits < - Allocator>::template rebind_alloc ElementAllocator; + using ElementAllocator = typename std::allocator_traits < + Allocator>::template rebind_alloc ; using ElementAllocatorTraits = std::allocator_traits ; - typedef typename std::allocator_traits < - Allocator>::template rebind_alloc BucketAllocator; + using BucketAllocator = typename std::allocator_traits < + Allocator>::template rebind_alloc ; using BucketAllocatorTraits = std::allocator_traits ; @@ -471,10 +470,10 @@ private: class Buckets { public: - typedef std::vector < + using vec_type = std::vector< bucket_type, typename std::allocator_traits :: - template rebind_alloc > vec_type; + template rebind_alloc >; Buckets () : m_max_load_factor (1.f) @@ -607,27 +606,27 @@ private: } public: - typedef Hash hasher; - typedef KeyEqual key_equal; - typedef Allocator allocator_type; - typedef value_type& reference; - typedef value_type const& const_reference; - typedef typename std::allocator_traits < - Allocator>::pointer pointer; - typedef typename std::allocator_traits < - Allocator>::const_pointer const_pointer; + using hasher = Hash; + using key_equal = KeyEqual; + using allocator_type = Allocator; + using reference = value_type&; + using const_reference = value_type const&; + using pointer = typename std::allocator_traits < + Allocator>::pointer; + using const_pointer = typename std::allocator_traits < + Allocator>::const_pointer; - // A set (that is, !IsMap) iterator is aways const because the elements - // of a set are immutable. - typedef detail::aged_container_iterator iterator; - typedef detail::aged_container_iterator const_iterator; + // A set iterator (IsMap==false) is always const + // because the elements of a set are immutable. + using iterator= detail::aged_container_iterator ; + using const_iterator = detail::aged_container_iterator ; - typedef detail::aged_container_iterator local_iterator; - typedef detail::aged_container_iterator const_local_iterator; + using local_iterator = detail::aged_container_iterator ; + using const_local_iterator = detail::aged_container_iterator ; //-------------------------------------------------------------------------- // @@ -641,16 +640,16 @@ public: class chronological_t { public: - // A set (that is, !IsMap) iterator is aways const because the elements - // of a set are immutable. - typedef detail::aged_container_iterator iterator; - typedef detail::aged_container_iterator const_iterator; - typedef detail::aged_container_iterator reverse_iterator; - typedef detail::aged_container_iterator const_reverse_iterator; + // A set iterator (IsMap==false) is always const + // because the elements of a set are immutable. + using iterator = detail::aged_container_iterator < + ! IsMap, typename list_type::iterator>; + using const_iterator = detail::aged_container_iterator < + true, typename list_type::iterator>; + using reverse_iterator = detail::aged_container_iterator < + ! IsMap, typename list_type::reverse_iterator>; + using const_reverse_iterator = detail::aged_container_iterator < + true, typename list_type::reverse_iterator>; iterator begin () { @@ -748,6 +747,8 @@ public: // //-------------------------------------------------------------------------- + aged_unordered_container() = delete; + explicit aged_unordered_container (clock_type& clock); aged_unordered_container (clock_type& clock, Hash const& hash); @@ -2436,7 +2437,7 @@ operator== ( { if (size() != other.size()) return false; - typedef std::pair EqRng; + using EqRng = std::pair ; for (auto iter (cbegin()), last (cend()); iter != last;) { auto const& k (extract (*iter));