Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the amount of content included by <array> #482

Merged
merged 6 commits into from
Feb 21, 2020

Conversation

BillyONeal
Copy link
Member

@BillyONeal BillyONeal commented Feb 5, 2020

Resolves GH-462.

Made the following changes to have fewer dependencies from <array>:

  • Demote back_inserter to <iterator>.
  • Demote _Yarn to <xlocinfo>.
  • Demote _Tidy_guard, _Tidy_deallocate_guard, and _Nothrow_compare to <xmemory>.
  • Promote _Swap_ranges_unchecked to <xutility>.
  • Change <array> to include only <xutility>.

This broke several real world code projects that only included <array> and called std::min or std::max. Therefore, the following workarounds were applied:

  • Remove the _STL_ASSERT from std::min and std::max. We normally guard every op< with debug checks, but in this case we aren't using it to enforce something like a container invariant; the number of bad op<s we catch with it are likely microscopic.
  • Delete _Min_value and _Max_value from <utility>.
  • Move min and max to <utility> (in the exact position as the old _Min_value and _Max_value), except for the initializer_list overloads.
  • Change all existing callers of _Min_value and _Max_value to call (_STD min) and (_STD max), respectively.

Checklist

  • Identifiers in product code changes are properly _Ugly as per
    https://eel.is/c++draft/lex.name#3.1 or there are no product code changes.
  • The STL builds successfully and all tests have passed (must be manually
    verified by an STL maintainer before automated testing is enabled on GitHub,
    leave this unchecked for initial submission).
  • These changes introduce no known ABI breaks (adding members, renaming
    members, adding virtual functions, changing whether a type is an aggregate
    or trivially copyable, etc.).
  • These changes were written from scratch using only this repository,
    the C++ Working Draft (including any cited standards), other WG21 papers
    (excluding reference implementations outside of proposed standard wording),
    and LWG issues as reference material. If they were derived from a project
    that's already listed in NOTICE.txt, that's fine, but please mention it.
    If they were derived from any other project (including Boost and libc++,
    which are not yet listed in NOTICE.txt), you must mention it here,
    so we can determine whether the license is compatible and what else needs
    to be done.

Resolves microsoftGH-462.

* Demote `back_inserter` and `iterator` to `<iterator>`.
* Demote `_Yarn` to `<xlocinfo>`.
* Demote `_Tidy_guard`, `_Tidy_deallocate_guard`, and `_Nothrow_compare` to `<xmemory>`.
* Promote `_Swap_ranges_unchecked` to `<xutility>`.
* Change `<array>` to include only `<xutility>`.
@BillyONeal BillyONeal requested a review from a team as a code owner February 5, 2020 05:30
@BillyONeal BillyONeal self-assigned this Feb 5, 2020
@BillyONeal
Copy link
Member Author

Some of these changes might have to be scaled back depending on what comes back from the Microsoft-internal "RWC" test system. (That is, if too much real world code is broken)

@BillyONeal
Copy link
Member Author

@ned14 I hope you're happy :)

stl/inc/xutility Show resolved Hide resolved
stl/inc/xutility Outdated Show resolved Hide resolved
stl/inc/xlocinfo Show resolved Hide resolved
@StephanTLavavej StephanTLavavej added the throughput Must compile faster label Feb 5, 2020
@BillyONeal
Copy link
Member Author

BillyONeal commented Feb 7, 2020

OK, results from RWC back:

  • MongoDB needs a patch; they have some TU which wants std::min/std::max from somewhere they probably got from <array> before
  • Pybind needs a patch, they have a header that wants std::min/std::max without <algorithm>.
    • Tensorflow needs a patch; they bundle Pybind
  • Mysql needs patches, they want tie and stdint.h constants without including the right headers.
  • Mame might need patches; they want ostream in some TUs, but RWC build before mine was unhappy with Mame so it might not be this change.

Investigating submitting upstream patches in these projects.

@BillyONeal
Copy link
Member Author

Given that most of the projects are broken by min/max I'm going to make the following changes:

  • Remove the _STL_ASSERT from std::min and std::max. We normally guard every op< with debug checks, but in this case we aren't using it to enforce something like a container invariant; the number of bad op<s we catch with it are likely microscopic.
  • Delete _Min_value and _Max_value from <utility>.
  • Move min and max to <utility> (in the exact position as the old _Min_value and _Max_value)
  • Change all existing callers of _Min_value and _Max_value to call (_STD min) and (_STD max), respectively.

…ome from <array>.

* Remove the `_STL_ASSERT` from `std::min` and `std::max`. We normally guard every `op<` with debug checks, but in this case we aren't using it to enforce something like a container invariant; the number of bad op<s we catch with it are likely microscopic.
* Delete `_Min_value` and `_Max_value` from `<utility>`.
* Move `min` and `max` to `<utility>` (in the exact position as the old `_Min_value` and `_Max_value`)
* Change all existing callers of `_Min_value` and `_Max_value` to call `(_STD min)` and `(_STD max)`, respectively.
stl/inc/xmemory Show resolved Hide resolved
@BillyONeal BillyONeal merged commit 482f1d8 into microsoft:master Feb 21, 2020
fengjixuchui added a commit to fengjixuchui/STL that referenced this pull request Feb 21, 2020
Reduce the amount of content included by <array> (microsoft#482)
@BillyONeal BillyONeal deleted the cleanup_array branch February 21, 2020 15:38
StephanTLavavej added a commit to AdamBucior/STL that referenced this pull request Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
throughput Must compile faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<array>: <array> includes too much stuff
3 participants