This is an archive of the discontinued LLVM Phabricator instance.

Implement `std::experimental::ostream_joiner`
ClosedPublic

Authored by mclow.lists on Jan 26 2016, 3:08 PM.

Details

Summary

This is part of the Library Fundamentals 2 TS

Diff Detail

Event Timeline

mclow.lists retitled this revision from to Implement `std::experimental::ostream_joiner`.
mclow.lists updated this object.
mclow.lists added reviewers: EricWF, howard.hinnant.
mclow.lists added a subscriber: cfe-commits.
EricWF edited edge metadata.Jan 27 2016, 3:47 PM
  • Please add the header to test/libcxx/double_include.sh.cpp
  • Please add a _LIBCPP_VERSION test in test/libcxx/experimental/iterator
  • The ostream_joiner type and it's members should be given visibility attributes.
include/experimental/iterator
62 ↗(On Diff #46059)

Wrong namespace. This gives std::experimental::fundamentals_v2. This brings up the bigger question of how we want to manage two TS's.

64 ↗(On Diff #46059)

Is _Delim allowed to be a reference? We might get better diagnostics if we static assert some requirements on _Delim.

85 ↗(On Diff #46059)

People are going to try and use this as an assignment operator. We either need to static assert in the body, or disable the operator entirely.
I'm not sure which is better. It depends on if we want a generated operator=.

94 ↗(On Diff #46059)

Unrelated note: Are we ever going to stop guarding noexcept behind a macro?

test/std/experimental/iterator/nothing_to_do.pass.cpp
2

LIT will only emit a warning if all sub directories are empty as well. Do we need this file for testit^

test/std/experimental/iterator/ostream.joiner/ostream.joiner.creation/make_ostream_joiner.pass.cpp
36

Can you test that joiner has the expected type?

test/std/experimental/iterator/ostream.joiner/ostream.joiner.ops/ostream_joiner.op.assign.pass.cpp
38

Nice test. Is there a reason to pass the delimiter as const here? It seems equally valid that the mutating delimiter has a non-const operator<<.

EricWF added inline comments.Jan 27 2016, 3:59 PM
include/experimental/iterator
85 ↗(On Diff #46059)

Disregard the comment above. It's not possible to call this with an instance of ostream_joiner. I thought it might be possible like it is with constructors.

mclow.lists added inline comments.Jan 27 2016, 5:28 PM
include/experimental/iterator
62 ↗(On Diff #46059)

I think that the right thing is to flip all the LFTS over to v2.

94 ↗(On Diff #46059)

Maybe. Depends on how much work it turns out to be.

I don't want to make that decision here, though.

test/std/experimental/iterator/nothing_to_do.pass.cpp
2

Well, if anyone was still running testit, yes.
But it's a nice simple test. Does including the header file actually work?

See test/std/experimental/optional or string_view for similar tests.

test/std/experimental/iterator/ostream.joiner/ostream.joiner.creation/make_ostream_joiner.pass.cpp
36

Sure.

test/std/experimental/iterator/ostream.joiner/ostream.joiner.ops/ostream_joiner.op.assign.pass.cpp
38

I'll add that as well.

mclow.lists edited edge metadata.

Addressed Eric's comments. (at least some of them)

mclow.lists marked 4 inline comments as done.Jan 27 2016, 5:34 PM

One last thing. The spec implicitly defines the copy/move/assignment operators for "ostream_joiner" by making "_Delim" an exposition only member. Essentially "ostream_joiner" should only copy/moveable if "_Delim" is. I think we should add tests that ensure we actually follow this behavior.

test/std/experimental/iterator/nothing_to_do.pass.cpp
3

Maybe call it "include_header.pass.cpp" then.

Add the tests that Eric suggested. Had to toss in a decay.

EricWF accepted this revision.Jan 27 2016, 6:59 PM
EricWF edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Jan 27 2016, 6:59 PM
mclow.lists closed this revision.Jan 27 2016, 8:20 PM

Landed as r259014 and r259015.