Title
Flat maps' deduction guide needs to default Allocator to be useful
Status
open
Section
[flat.map.defn][flat.multimap.defn]
Submitter
Johel Ernesto Guerrero Peña

Created on 2022-09-25.00:00:00 last changed 1 month ago

Messages

Date: 2022-10-20.08:15:22

Proposed resolution:

This wording is relative to N4917.

  1. Modify [container.adaptors.general] as indicated:

    -8- The following exposition-only alias templates may appear in deduction guides for container adaptors:

    template<class Container>
      using cont-key-type =                                // exposition only
        remove_const_t<typename Container::value_type::first_type>;
    template<class Container>
      using cont-mapped-type =                             // exposition only
        typename Container::value_type::second_type;
    template<class Allocator, class T>
      using alloc-rebind =                             // exposition only
        typename allocator_traits<Allocator>::template rebind_alloc<T>;
    
    
  2. Modify [flat.map.defn], class template flat_map synopsis, as indicated:

    […]
    template<ranges::input_range R, class Compare = less<range-key-type<R>>,
             class Allocator = allocator<void>>
      flat_map(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
        -> flat_map<range-key-type<R>, range-mapped-type<R>, Compare,
             vector<range-key-type<R>, alloc-rebind<Allocator, range-key-type<R>>,
             vector<range-mapped-type<R>, alloc-rebind<Allocator, range-mapped-type<R>>>;
    
    template<ranges::input_range R, class Allocator>
      flat_map(from_range_t, R&&, Allocator)
        -> flat_map<range-key-type<R>, range-mapped-type<R>, less<range-key-type<R>>,
             vector<range-key-type<R>, alloc-rebind<Allocator, range-key-type<R>>,
             vector<range-mapped-type<R>, alloc-rebind<Allocator, range-mapped-type<R>>>;
    […]
    
  3. Modify [flat.multimap.defn], class template flat_multimap synopsis, as indicated:

    […]
    template<ranges::input_range R, class Compare = less<range-key-type<R>>,
             class Allocator = allocator<void>>
      flat_multimap(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
        -> flat_multimap<range-key-type<R>, range-mapped-type<R>, Compare,
             vector<range-key-type<R>, alloc-rebind<Allocator, range-key-type<R>>,
             vector<range-mapped-type<R>, alloc-rebind<Allocator, range-mapped-type<R>>>;
    
    template<ranges::input_range R, class Allocator>
      flat_multimap(from_range_t, R&&, Allocator)
        -> flat_multimap<range-key-type<R>, range-mapped-type<R>, less<range-key-type<R>>,
             vector<range-key-type<R>, alloc-rebind<Allocator, range-key-type<R>>,
             vector<range-mapped-type<R>, alloc-rebind<Allocator, range-mapped-type<R>>>;
    […]
    
  4. Modify [flat.set.defn], class template flat_set synopsis, as indicated:

    […]
    template<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>,
             class Allocator = allocator<ranges::range_value_t<R>>>
      flat_set(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
        -> flat_set<ranges::range_value_t<R>, Compare,
             vector<ranges::range_value_t<R>, alloc-rebind<Allocator, ranges::range_value_t<R>>>>;
    
    template<ranges::input_range R, class Allocator>
      flat_set(from_range_t, R&&, Allocator)
        -> flat_set<ranges::range_value_t<R>, less<ranges::range_value_t<R>>,
             vector<ranges::range_value_t<R>, alloc-rebind<Allocator, ranges::range_value_t<R>>>>;
    […]
    
  5. Modify [flat.multiset.defn], class template flat_multiset synopsis, as indicated:

    […]
    template<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>,
             class Allocator = allocator<ranges::range_value_t<R>>>
      flat_multiset(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
        -> flat_multiset<ranges::range_value_t<R>, Compare,
             vector<ranges::range_value_t<R>, alloc-rebind<Allocator, ranges::range_value_t<R>>>>;
    
    template<ranges::input_range R, class Allocator>
      flat_multiset(from_range_t, R&&, Allocator)
        -> flat_multiset<ranges::range_value_t<R>, less<ranges::range_value_t<R>>,
             vector<ranges::range_value_t<R>, alloc-rebind<Allocator, ranges::range_value_t<R>>>>;
    […]
    
Date: 2022-10-15.00:00:00

[ 2022-10-19; Jonathan provides improved wording ]

Date: 2022-09-15.00:00:00

[ 2022-09-28; LWG telecon ]

We should not just ignore the allocator, it should be rebound and used for the two container types.

Previous resolution [SUPERSEDED]:

This wording is relative to N4917.

  1. Modify [flat.map.defn], class template flat_map synopsis, as indicated:

    […]
    template<ranges::input_range R, class Compare = less<range-key-type<R>>,
             class Allocator = allocator<void>>
      flat_map(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
        -> flat_map<range-key-type<R>, range-mapped-type<R>, Compare>;
    […]
    
  2. Modify [flat.multimap.defn], class template flat_multimap synopsis, as indicated:

    […]
    template<ranges::input_range R, class Compare = less<range-key-type<R>>,
             class Allocator = allocator<void>>
      flat_multimap(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
        -> flat_multimap<range-key-type<R>, range-mapped-type<R>, Compare>;
    […]
    
Date: 2022-09-25.00:00:00

This originated from the editorial issue #5800.

P0429R9 added some deduction guides with a non-defaulted Allocator template parameter and a corresponding function parameter that is defaulted. Since the template parameter Allocator is not defaulted, these deduction guides are never used.

History
Date User Action Args
2022-10-19 19:43:42adminsetmessages: + msg12871
2022-10-06 17:09:10adminsetmessages: + msg12841
2022-10-06 17:09:10adminsetstatus: new -> open
2022-09-25 11:23:04adminsetmessages: + msg12814
2022-09-25 00:00:00admincreate