Rewrite CTAD and SFINAE-out overloads as the standard requires

This commit is contained in:
Ion Gaztañaga
2018-11-12 22:52:45 +01:00
parent 204c30d8ec
commit cb21746b80
23 changed files with 869 additions and 316 deletions
+106 -119
View File
@@ -319,6 +319,21 @@ class flat_map
: m_flat_tree(ordered_range, first, last, comp, dtl::force<const impl_allocator_type>(a))
{}
//! <b>Effects</b>: Constructs an empty flat_map using the specified allocator and
//! inserts elements from the ordered range [first ,last). This function
//! is more efficient than the normal range creation for ordered ranges.
//!
//! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
//!
//! <b>Complexity</b>: Linear in N.
//!
//! <b>Note</b>: Non-standard extension.
template <class InputIterator>
BOOST_CONTAINER_FORCEINLINE
flat_map(ordered_unique_range_t, InputIterator first, InputIterator last, const allocator_type& a)
: m_flat_tree(ordered_range, first, last, Compare(), a)
{}
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
//! <b>Effects</b>: Constructs an empty flat_map and
//! inserts elements from the range [il.begin() ,il.end()).
@@ -1563,89 +1578,63 @@ class flat_map
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
};
#if __cplusplus >= 201703L
#ifndef BOOST_CONTAINER_NO_CXX17_CTAD
template <typename InputIterator>
flat_map(InputIterator, InputIterator) ->
flat_map< typename dtl::remove_const< typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type>;
flat_map< it_based_non_const_first_type_t<InputIterator>
, it_based_second_type_t<InputIterator>>;
#ifdef BOOST_HAS_CTAD_SFINAE
namespace dtl {
template<class T, class U>
using enable_if_allocator_t = std::enable_if_t<std::is_same_v<decltype(std::declval<T>().allocate(0)), U *>, T>;
template<class T, class U>
using enable_if_compare_t = std::enable_if_t<std::is_same_v<decltype(std::declval<T>()(std::declval<U>(), std::declval<U>())), bool>, T>;
} // namespace dtl
template <typename InputIterator, typename Allocator>
template < typename InputIterator, typename Allocator
, typename = dtl::require_allocator_t<Allocator>>
flat_map(InputIterator, InputIterator, Allocator const&) ->
flat_map< typename dtl::remove_const< typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type
, std::less<typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type>
, dtl::enable_if_allocator_t<Allocator, std::remove_const_t<typename iterator_traits<InputIterator>::value_type>>>;
flat_map< it_based_non_const_first_type_t<InputIterator>
, it_based_second_type_t<InputIterator>
, std::less<it_based_non_const_first_type_t<InputIterator>>
, Allocator>;
template <typename InputIterator, typename Compare>
template < typename InputIterator, typename Compare
, typename = dtl::require_nonallocator_t<Compare>>
flat_map(InputIterator, InputIterator, Compare const&) ->
flat_map< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type
, dtl::enable_if_compare_t<Compare, std::remove_const_t<typename iterator_traits<InputIterator>::value_type::first_type>>>;
#else
template <typename InputIterator, typename Compare>
flat_map(InputIterator, InputIterator, Compare const&) ->
flat_map< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type
flat_map< it_based_non_const_first_type_t<InputIterator>
, it_based_second_type_t<InputIterator>
, Compare>;
#endif
template <typename InputIterator, typename Compare, typename Allocator>
template < typename InputIterator, typename Compare, typename Allocator
, typename = dtl::require_nonallocator_t<Compare>
, typename = dtl::require_allocator_t<Allocator>>
flat_map(InputIterator, InputIterator, Compare const&, Allocator const&) ->
flat_map< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type
flat_map< it_based_non_const_first_type_t<InputIterator>
, it_based_second_type_t<InputIterator>
, Compare
, Allocator>;
template <typename InputIterator>
flat_map(ordered_unique_range_t, InputIterator, InputIterator) ->
flat_map< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type>;
flat_map< it_based_non_const_first_type_t<InputIterator>
, it_based_second_type_t<InputIterator>>;
#ifdef BOOST_HAS_CTAD_SFINAE
template <typename InputIterator, typename Allocator>
template < typename InputIterator, typename Allocator
, typename = dtl::require_allocator_t<Allocator>>
flat_map(ordered_unique_range_t, InputIterator, InputIterator, Allocator const&) ->
flat_map< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type
, std::less<typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type>
, dtl::enable_if_allocator_t<Allocator, std::remove_const_t<typename iterator_traits<InputIterator>::value_type>>>;
flat_map< it_based_non_const_first_type_t<InputIterator>
, it_based_second_type_t<InputIterator>
, std::less<it_based_non_const_first_type_t<InputIterator>>
, Allocator>;
template <typename InputIterator, typename Compare>
template < typename InputIterator, typename Compare
, typename = dtl::require_nonallocator_t<Compare>>
flat_map(ordered_unique_range_t, InputIterator, InputIterator, Compare const&) ->
flat_map< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type
, dtl::enable_if_compare_t<Compare, std::remove_const_t<typename iterator_traits<InputIterator>::value_type::first_type>>>;
#else
template <typename InputIterator, typename Compare>
flat_map(ordered_unique_range_t, InputIterator, InputIterator, Compare const&) ->
flat_map< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type
flat_map< it_based_non_const_first_type_t<InputIterator>
, it_based_second_type_t<InputIterator>
, Compare>;
#endif
template <typename InputIterator, typename Compare, typename Allocator>
template < typename InputIterator, typename Compare, typename Allocator
, typename = dtl::require_nonallocator_t<Compare>
, typename = dtl::require_allocator_t<Allocator>>
flat_map(ordered_unique_range_t, InputIterator, InputIterator, Compare const&, Allocator const&) ->
flat_map< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type
flat_map< it_based_non_const_first_type_t<InputIterator>
, it_based_second_type_t<InputIterator>
, Compare
, Allocator>;
@@ -1912,6 +1901,21 @@ class flat_multimap
: m_flat_tree(ordered_range, first, last, comp, a)
{}
//! <b>Effects</b>: Constructs an empty flat_multimap using the specified comparison object and
//! inserts elements from the ordered range [first ,last). This function
//! is more efficient than the normal range creation for ordered ranges.
//!
//! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
//!
//! <b>Complexity</b>: Linear in N.
//!
//! <b>Note</b>: Non-standard extension.
template <class InputIterator>
BOOST_CONTAINER_FORCEINLINE
flat_multimap(ordered_range_t, InputIterator first, InputIterator last, const allocator_type &a)
: m_flat_tree(ordered_range, first, last, Compare(), a)
{}
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
//! <b>Effects</b>: Constructs an empty flat_map and
//! inserts elements from the range [il.begin(), il.end()).
@@ -2880,82 +2884,65 @@ class flat_multimap
{ x.swap(y); }
};
#if __cplusplus >= 201703L
#ifndef BOOST_CONTAINER_NO_CXX17_CTAD
template <typename InputIterator>
flat_multimap(InputIterator, InputIterator) ->
flat_multimap<typename dtl::remove_const< typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type>;
flat_multimap< it_based_non_const_first_type_t<InputIterator>
, it_based_second_type_t<InputIterator>>;
#ifdef BOOST_HAS_CTAD_SFINAE
template <typename InputIterator, typename Allocator>
template < typename InputIterator, typename Allocator
, typename = dtl::require_allocator_t<Allocator>>
flat_multimap(InputIterator, InputIterator, Allocator const&) ->
flat_multimap<typename dtl::remove_const< typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type
, std::less<typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type>
, dtl::enable_if_allocator_t<Allocator, std::remove_const_t<typename iterator_traits<InputIterator>::value_type>>>;
flat_multimap< it_based_non_const_first_type_t<InputIterator>
, it_based_second_type_t<InputIterator>
, std::less<it_based_non_const_first_type_t<InputIterator>>
, Allocator>;
template <typename InputIterator, typename Compare>
template < typename InputIterator, typename Compare
, typename = dtl::require_nonallocator_t<Compare>>
flat_multimap(InputIterator, InputIterator, Compare const&) ->
flat_multimap< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type
, dtl::enable_if_compare_t<Compare, std::remove_const_t<typename iterator_traits<InputIterator>::value_type::first_type>>>;
flat_multimap< it_based_non_const_first_type_t<InputIterator>
, it_based_second_type_t<InputIterator>
, Compare>;
#else
template <typename InputIterator, typename Compare>
flat_multimap(InputIterator, InputIterator, Compare const&) ->
flat_multimap< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type
, Compare>;
#endif
template <typename InputIterator, typename Compare, typename Allocator>
template < typename InputIterator, typename Compare, typename Allocator
, typename = dtl::require_nonallocator_t<Compare>
, typename = dtl::require_allocator_t<Allocator>>
flat_multimap(InputIterator, InputIterator, Compare const&, Allocator const&) ->
flat_multimap< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type
, Compare
, Allocator>;
flat_multimap< it_based_non_const_first_type_t<InputIterator>
, it_based_second_type_t<InputIterator>
, Compare
, Allocator>;
template <typename InputIterator>
flat_multimap(ordered_range_t, InputIterator, InputIterator) ->
flat_multimap< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type>;
flat_multimap< it_based_non_const_first_type_t<InputIterator>
, it_based_second_type_t<InputIterator>>;
#ifdef BOOST_HAS_CTAD_SFINAE
template <typename InputIterator, typename Allocator>
template < typename InputIterator, typename Allocator
, typename = dtl::require_allocator_t<Allocator>>
flat_multimap(ordered_range_t, InputIterator, InputIterator, Allocator const&) ->
flat_multimap< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type
, std::less<typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type>
, dtl::enable_if_allocator_t<Allocator, std::remove_const_t<typename iterator_traits<InputIterator>::value_type>>>;
flat_multimap< it_based_non_const_first_type_t<InputIterator>
, it_based_second_type_t<InputIterator>
, std::less<it_based_non_const_first_type_t<InputIterator>>
, Allocator>;
template <typename InputIterator, typename Compare>
template < typename InputIterator, typename Compare
, typename = dtl::require_nonallocator_t<Compare>>
flat_multimap(ordered_range_t, InputIterator, InputIterator, Compare const&) ->
flat_multimap< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type
, dtl::enable_if_compare_t<Compare, std::remove_const_t<typename iterator_traits<InputIterator>::value_type::first_type>>>;
flat_multimap< it_based_non_const_first_type_t<InputIterator>
, it_based_second_type_t<InputIterator>
, Compare>;
#else
template <typename InputIterator, typename Compare>
flat_multimap(ordered_range_t, InputIterator, InputIterator, Compare const&) ->
flat_multimap< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type
, Compare>;
#endif
template <typename InputIterator, typename Compare, typename Allocator>
template < typename InputIterator, typename Compare, typename Allocator
, typename = dtl::require_nonallocator_t<Compare>
, typename = dtl::require_allocator_t<Allocator>>
flat_multimap(ordered_range_t, InputIterator, InputIterator, Compare const&, Allocator const&) ->
flat_multimap< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type
, typename iterator_traits<InputIterator>::value_type::second_type
, Compare
, Allocator>;
flat_multimap< it_based_non_const_first_type_t<InputIterator>
, it_based_second_type_t<InputIterator>
, Compare
, Allocator>;
#endif