Skip to content

Conversation

@Intedai
Copy link
Contributor

@Intedai Intedai commented May 8, 2025

River (@wusatosi ):
fixes #79
fixes #73

@Intedai Intedai requested a review from a team May 8, 2025 13:05
@Intedai
Copy link
Contributor Author

Intedai commented May 8, 2025

Issue: #73

Copy link
Member

@JeffGarland JeffGarland left a comment

Choose a reason for hiding this comment

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

This looks good to me.

Of course I'm realizing this repo basically doesn't have any testing turned on! ugh! New issue incoming...

I see you have to click approve and run workflows for the CI to run.

edit: Forgot to say welcome @Intedai - thank you for your contribution!

@Intedai
Copy link
Contributor Author

Intedai commented May 8, 2025

This looks good to me.

Of course I'm realizing this repo basically doesn't have any testing turned on! ugh! New issue incoming...

I see you have to click approve and run workflows for the CI to run.

edit: Forgot to say welcome @Intedai - thank you for your contribution!

Thanks! 😃

@JeffGarland
Copy link
Member

Please merge when ready.

Copy link
Member

@DeveloperPaul123 DeveloperPaul123 left a comment

Choose a reason for hiding this comment

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

Looks good to me! Nice work 👍

private: // Utilities
constexpr void assert_iterator_in_range(const_iterator it) noexcept {
constexpr void
assert_iterator_in_range([[maybe_unused]] const_iterator it) noexcept {
Copy link
Member

Choose a reason for hiding this comment

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

These functions are left over artifacts from the original reference implementation. iirc they're not used anywhere, IV_EXPECT is defined as a no-op currently, I think it's safe to remove all these artifacts

Comment on lines +323 to 327
static constexpr void
unsafe_set_size([[maybe_unused]] size_t new_size) noexcept {
IV_EXPECT(new_size == 0 &&
"tried to change size of empty storage to non-zero value");
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static constexpr void
unsafe_set_size([[maybe_unused]] size_t new_size) noexcept {
IV_EXPECT(new_size == 0 &&
"tried to change size of empty storage to non-zero value");
}
static constexpr void
unsafe_set_size(size_t) noexcept {}

Does this work?
This is assuming we remove all the assertion related artifact.

Copy link
Member

@wusatosi wusatosi left a comment

Choose a reason for hiding this comment

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

Thanks for the help, we can remove the artifacts from the assertion factilities in another PR.

@JeffGarland
Copy link
Member

Thanks for the help, we can remove the artifacts from the assertion factilities in another PR.

we should make an issue for this work. I think, without looking at the original, the intent of these are to be static asserts for preconditions which could be enabled. So if we agree that this is the case we should consider seeing if we can get a compiler with contracts and turn them into contract preconditions -- and maybe otherwise they just turn into asserts.

See this paper https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3471r4.html for details. Just to extract one thing:

As an example:

a.front()
Modify 23.2.4 [sequence.reqmts] around paragraph 69 as indicated:
a.front()
69 Result: reference; const_reference for constant a.
70 Hardened preconditions: a.empty() is false.
71 Returns: *a.begin()
72 Remarks: Required for basic_string, array, deque, forward_list, inplace_vector, list, and vector.

Copy link
Collaborator

@20162026 20162026 left a comment

Choose a reason for hiding this comment

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

there is some more comment cruft left at:

// constexpr void resize(size_type sz);

// constexpr const_reference at(size_type n) const;

// constexpr friend auto /*synth-three-way-result<T>*/

@wusatosi
Copy link
Member

wusatosi commented May 8, 2025

we should make an issue for this work. I think, without looking at the original, the intent of these are to be static asserts for preconditions which could be enabled. So if we agree that this is the case we should consider seeing if we can get a compiler with contracts and turn them into contract preconditions -- and maybe otherwise they just turn into asserts.

As far as I know there hasn't been any compiler releases that support contracts. Let's hold this off till there's some compiler support as we currently do not have infrastructures that builds custom compilers for POCs.

Can you open an issue about this? For now I think we should simply remove all the artifact. We can do this in another PR or in the same PR.

@JeffGarland
Copy link
Member

we should make an issue for this work. I think, without looking at the original, the intent of these are to be static asserts for preconditions which could be enabled. So if we agree that this is the case we should consider seeing if we can get a compiler with contracts and turn them into contract preconditions -- and maybe otherwise they just turn into asserts.

As far as I know there hasn't been any compiler releases that support contracts.

If you look on godbolt at least gcc has several experimental versions with contracts -- I'm not sure which one (if any) corresponds to P2900.

Let's hold this off till there's some compiler support as we currently do not have infrastructures that builds custom compilers for POCs.

Again, there's nothing stopping someone from making those plain old assert checks -- contracts is just a fancier way to do that and have more control over the runtime results.

Can you open an issue about this? For now I think we should simply remove all the artifact. We can do this in another PR or in the same PR.

Done: #78

@wusatosi
Copy link
Member

wusatosi commented May 9, 2025

If you look on godbolt at least gcc has several experimental versions with contracts -- I'm not sure which one (if any) corresponds to P2900.

We have no infrastructure to test on experimental versions of gcc, this is on my road map but it's not there yet. I am still very much against putting things in that are not testable.

Again, there's nothing stopping someone from making those plain old assert checks -- contracts is just a fancier way to do that and have more control over the runtime results.

We can bring back the assertion facilities if that's what you're suggesting.

Thanks for opening the issue.


#undef IV_EXPECT

#endif // BEMAN_INPLACE_VECTOR_INPLACE_VECTOR_HPP
Copy link
Contributor

Choose a reason for hiding this comment

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

[pre-commit] reported by reviewdog 🐶

Suggested change
#endif // BEMAN_INPLACE_VECTOR_INPLACE_VECTOR_HPP
#endif // BEMAN_INPLACE_VECTOR_INPLACE_VECTOR_HPP

@Intedai
Copy link
Contributor Author

Intedai commented May 10, 2025

Fixed merge conflict, sorry about the second commit accidentally removed the new line at the end 😢

@wusatosi
Copy link
Member

Fixed merge conflict, sorry about the second commit accidentally removed the new line at the end 😢

No you're fine, thanks for helping out!

There's a bit more cruft left, see @20162026 's comment.

Otherwise let me know when you think this PR is ready to merge.

@Intedai
Copy link
Contributor Author

Intedai commented May 10, 2025

@wusatosi I removed the remaining cruft, I'm pretty sure the pr is ready to merge

@JeffGarland JeffGarland merged commit b8aabf6 into bemanproject:main May 10, 2025
25 checks passed
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.

warning C4068: unknown pragma 'GCC' cleanup implementation comments

5 participants