Skip to content

<functional> Implement bind_front()#158

Merged
StephanTLavavej merged 5 commits into
microsoft:masterfrom
NathanSWard:bind_front_impl
Oct 23, 2019
Merged

<functional> Implement bind_front()#158
StephanTLavavej merged 5 commits into
microsoft:masterfrom
NathanSWard:bind_front_impl

Conversation

@NathanSWard

Copy link
Copy Markdown
Contributor

Description

This is an implementation of std::bind_front(). Addresses issue #13

Checklist

  • I understand README.md. I also understand that acceptance of
    community PRs will be delayed until the test and CI systems are online.
  • If this is a feature addition, that feature has been voted into the
    C++ Working Draft.
  • Identifiers in product code changes are properly _Ugly as per
    https://eel.is/c++draft/lex.name#3.1 .
  • The STL builds successfully and all tests have passed (must be manually
    verified by an STL maintainer before CI is online, 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 and
    the C++ Working Draft as a reference (and any other cited standards).
    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.

@NathanSWard NathanSWard requested a review from a team as a code owner October 4, 2019 03:22
@msftclas

msftclas commented Oct 4, 2019

Copy link
Copy Markdown

CLA assistant check
All CLA requirements met.

@StephanTLavavej StephanTLavavej left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • You need to mention the new feature in yvals_core.h in the _HAS_CXX20 section in sorted order. We use the corresponding issue title, so it should be listed as P0356R5 bind_front().
  • You need to update _MSVC_STL_UPDATE in yvals_core.h when adding a new feature, since it's a new month.
  • You also need to define the feature-test macro __cpp_lib_bind_front in yvals_core.h.
  • This should indeed be constexpr.

Excellent use of _NODISCARD - bind_front() should never be discarded (why call it?) but operator() can easily be discarded if the bound functor has useful side effects.

Comment thread stl/inc/functional Outdated
Comment thread stl/inc/functional Outdated
Comment thread stl/inc/functional Outdated
Comment thread stl/inc/functional Outdated
Comment thread stl/inc/functional Outdated
@StephanTLavavej

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@StephanTLavavej StephanTLavavej left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that this will be ready to be checked in after these last remaining issues are fixed. Thanks!

Comment thread stl/inc/yvals_core.h Outdated
Comment thread stl/inc/functional
Comment thread stl/inc/functional Outdated
Comment thread stl/inc/functional Outdated
@StephanTLavavej

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@StephanTLavavej

Copy link
Copy Markdown
Member

I'm preparing a Microsoft-internal PR for this, #193, and #195, with associated test changes.

@StephanTLavavej

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Comment thread stl/inc/functional Outdated
Comment thread stl/inc/functional Outdated
Comment thread stl/inc/yvals_core.h Outdated
Comment thread stl/inc/functional Outdated
Comment thread stl/inc/functional

@StephanTLavavej StephanTLavavej left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that this is sufficiently clear now, although clang-format varies the wrapping a little (due to varying line lengths). At this point I believe there is no need for more wrapping as the repetitive structure is scannable enough.

@StephanTLavavej

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@CaseyCarter CaseyCarter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved assuming test coverage.

@StephanTLavavej

Copy link
Copy Markdown
Member

While writing tests, I observe that WG21-P1651 claims "functors produced by std::bind_front are not assignable". I can't find any Standardese requiring them to be assignable, but I also can't find any Standardese requiring assignment to be ill-formed. Your bind_front() object behaves the same as the bind() object, so I think this is fine as-is.

@NathanSWard

Copy link
Copy Markdown
Contributor Author

@StephanTLavavej Ok! Though, let me know if you'd rather have me explicitly put _Front_binder(const _Front_binder&) = delete;.

@StephanTLavavej

Copy link
Copy Markdown
Member

Status update: I've sent out that Microsoft-internal PR with tests, so I should be able to merge this and the other PRs tomorrow.

@StephanTLavavej StephanTLavavej merged commit 379e617 into microsoft:master Oct 23, 2019
@NathanSWard NathanSWard deleted the bind_front_impl branch October 23, 2019 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants