[libcxx-commits] [PATCH] D143914: [libc++] Clean up pair's constructors and assignment operators

Jordan Rupprecht via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 13 19:51:40 PST 2023


rupprecht added a comment.

Still chugging away, looks like this is going to be at least 50 breakages. Most of them are trivial to fix (e.g. `return std::make_tuple()` in a method returning `std::pair` should be `return std::make_pair()`). There are a few that are a little surprising, such as this one which doesn't seem related to tuple compatibility:

  void func() {
    std::map<unsigned long, std::string> m;
  
    // OK
    std::vector<std::pair<unsigned long, std::string>> v1(m.begin(), m.end());
  
    // OK before, but now: error: no matching constructor for initialization
    std::vector<
        std::pair<const unsigned long, std::reference_wrapper<std::string>>>
        v2(m.begin(), m.end());
  }

With the full backtrace:

  D143914.cc:14:7: error: no matching constructor for initialization of 'std::vector<std::pair<const unsigned long, std::reference_wrapper<std::string>>>' (aka 'vector<pair<const unsigned long, reference_wrapper<basic_string<char>>>>')
        v2(m.begin(), m.end());
        ^  ~~~~~~~~~~~~~~~~~~
  vector:393:66: note: candidate constructor not viable: no known conversion from 'iterator' (aka '__map_iterator<__tree_iterator<std::__value_type<unsigned long, std::string>, std::__tree_node<std::__value_type<unsigned long, std::string>, void *> *, long>>') to 'size_type' (aka 'unsigned long') for 1st argument
      _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a);
                                                                   ^
  vector:395:57: note: candidate constructor not viable: no known conversion from 'iterator' (aka '__map_iterator<__tree_iterator<std::__value_type<unsigned long, std::string>, std::__tree_node<std::__value_type<unsigned long, std::string>, void *> *, long>>') to 'size_type' (aka 'unsigned long') for 1st argument
      _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x);
                                                          ^
  vector:463:57: note: candidate constructor not viable: no known conversion from 'iterator' (aka '__map_iterator<__tree_iterator<std::__value_type<unsigned long, std::string>, std::__tree_node<std::__value_type<unsigned long, std::string>, void *> *, long>>') to 'const vector<pair<const unsigned long, reference_wrapper<string>>>' for 1st argument
      _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x, const __type_identity_t<allocator_type>& __a);
                                                          ^
  vector:472:5: note: candidate constructor not viable: no known conversion from 'iterator' (aka '__map_iterator<__tree_iterator<std::__value_type<unsigned long, std::string>, std::__tree_node<std::__value_type<unsigned long, std::string>, void *> *, long>>') to 'initializer_list<value_type>' (aka 'initializer_list<std::pair<const unsigned long, std::reference_wrapper<std::string>>>') for 1st argument
      vector(initializer_list<value_type> __il, const allocator_type& __a);
      ^
  vector:488:5: note: candidate constructor not viable: no known conversion from 'iterator' (aka '__map_iterator<__tree_iterator<std::__value_type<unsigned long, std::string>, std::__tree_node<std::__value_type<unsigned long, std::string>, void *> *, long>>') to 'vector<pair<const unsigned long, reference_wrapper<string>>>' for 1st argument
      vector(vector&& __x, const __type_identity_t<allocator_type>& __a);
      ^
  vector:414:55: note: candidate template ignored: requirement '__is_exactly_cpp17_input_iterator<std::__map_iterator<std::__tree_iterator<std::__value_type<unsigned long, std::string>, std::__tree_node<std::__value_type<unsigned long, std::string>, void *> *, long>>>::value' was not satisfied [with _InputIterator = iterator]
    _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_InputIterator __first, _InputIterator __last);
                                                        ^
  vector:427:55: note: candidate template ignored: requirement 'is_constructible<std::pair<const unsigned long, std::reference_wrapper<std::string>>, std::pair<const unsigned long, std::string> &>::value' was not satisfied [with _ForwardIterator = iterator]
    _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_ForwardIterator __first, _ForwardIterator __last);
                                                        ^
  vector:381:66: note: candidate constructor not viable: requires single argument '__a', but 2 arguments were provided
      _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(const allocator_type& __a)
                                                                   ^
  vector:391:66: note: candidate constructor not viable: requires single argument '__n', but 2 arguments were provided
      _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n);
                                                                   ^
  vector:462:57: note: candidate constructor not viable: requires single argument '__x', but 2 arguments were provided
      _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x);
                                                          ^
  vector:469:5: note: candidate constructor not viable: requires single argument '__il', but 2 arguments were provided
      vector(initializer_list<value_type> __il);
      ^
  vector:480:5: note: candidate constructor not viable: requires single argument '__x', but 2 arguments were provided
      vector(vector&& __x)
      ^
  vector:399:5: note: candidate constructor template not viable: requires 3 arguments, but 2 were provided
      vector(size_type __n, const value_type& __x, const allocator_type& __a)
      ^
  vector:420:3: note: candidate constructor template not viable: requires 3 arguments, but 2 were provided
    vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
    ^
  vector:434:3: note: candidate constructor template not viable: requires 3 arguments, but 2 were provided
    vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a);
    ^
  vector:377:5: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
      vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
      ^


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143914/new/

https://reviews.llvm.org/D143914



More information about the libcxx-commits mailing list