Skip to content

Conversation

ComicSansMS
Copy link
Contributor

@ComicSansMS ComicSansMS commented Sep 10, 2025

Notes for Reviewer

Implementation of StaticString for C++ base library.

Pre-Review Checklist for the PR Author

  • Add sensible notes for the reviewer
  • PR title is short, expressive and meaningful
  • Consider switching the PR to a draft (Convert to draft)
    • as draft PR, the CI will be skipped for pushes
  • Relevant issues are linked in the References section
  • Every source code file has a copyright header with SPDX-License-Identifier: Apache-2.0 OR MIT
  • Branch follows the naming format (iox2-123-introduce-posix-ipc-example)
  • Commits messages are according to this guideline
  • Tests follow the best practice for testing
  • Changelog updated in the unreleased section including API breaking changes
  • Assign PR to reviewer
  • All checks have passed (except task-list-completed)

Checklist for the PR Reviewer

  • Commits are properly organized and messages are according to the guideline
  • Unit tests have been written for new behavior
  • Public API is documented
  • PR title describes the changes

Post-review Checklist for the PR Author

  • All open points are addressed and tracked via issues

References

Closes #938.

@ComicSansMS ComicSansMS force-pushed the iox2-938-base-library-static-string branch from c693bf5 to 48291bb Compare September 10, 2025 12:42
@ComicSansMS ComicSansMS marked this pull request as ready for review September 10, 2025 12:44
Copy link

codecov bot commented Sep 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.18%. Comparing base (f5972fc) to head (9a4aa9e).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1031      +/-   ##
==========================================
- Coverage   80.20%   80.18%   -0.02%     
==========================================
  Files         258      258              
  Lines       32252    32252              
==========================================
- Hits        25867    25862       -5     
- Misses       6385     6390       +5     

see 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@FerdinandSpitzschnueffler FerdinandSpitzschnueffler left a comment

Choose a reason for hiding this comment

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

I haven't reviewed the tests yet, but so far it looks good - just a few minor comments.

constexpr StaticString(StaticString const&) noexcept = default;
constexpr StaticString(StaticString&&) noexcept = default;

template <uint64_t M, std::enable_if_t<(N > M), bool> = true>
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about having a static_assert instead of the enable_if to provide the user a clearer error message why their code doesn't compile?

Copy link
Contributor Author

@ComicSansMS ComicSansMS Sep 12, 2025

Choose a reason for hiding this comment

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

static_assert does not play nice with SFINAE (at least not without resorting to some tricks), which makes it an inferior choice for restricting overload sets.
The problem with static_assert is that is evaluated too late: The constrained function will participate in overload resolution, same as all other candidates of the overloard set and the best match will win irrespective of constraints. Only then will the static_assert be evaluated and if its constraints fail it will be a hard error, as all other candidates have already been discarded. This is highly undesirable in contexts in which you want to handle a constraint failure as a recoverable compile time error, which is very common with overload sets.

I will think about how to improve the diagnostics here.

Copy link
Contributor

@FerdinandSpitzschnueffler FerdinandSpitzschnueffler left a comment

Choose a reason for hiding this comment

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

I started reviewing the tests; will continue next week.

Copy link
Contributor

@FerdinandSpitzschnueffler FerdinandSpitzschnueffler left a comment

Choose a reason for hiding this comment

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

Review done :)

@FerdinandSpitzschnueffler
Copy link
Contributor

Regarding the failing Windows builds: #1049

@ComicSansMS ComicSansMS force-pushed the iox2-938-base-library-static-string branch from 0fc8854 to eda8d79 Compare September 16, 2025 05:52
@orecham
Copy link
Contributor

orecham commented Sep 16, 2025

@ComicSansMS Just nitpicking here, don't need to change it in this PR, but just for information - the commits in this repository are conventionally written using the imperative form. You can see it in the commit history.

See this link, which is also included in the PR template:

Another nice article:

@ComicSansMS ComicSansMS force-pushed the iox2-938-base-library-static-string branch from eda8d79 to 4beed71 Compare September 16, 2025 08:48
@ComicSansMS
Copy link
Contributor Author

@ComicSansMS Just nitpicking here, don't need to change it in this PR, but just for information - the commits in this repository are conventionally written using the imperative form.

Thanks, I completely forgot about the imperative forms. I adjusted all commit messages.

@ComicSansMS ComicSansMS force-pushed the iox2-938-base-library-static-string branch from 4beed71 to 9a4aa9e Compare September 16, 2025 16:01
return std::all_of(str.unchecked_access().data() + str.size(),
str.unchecked_access().data() + str.capacity() + 1,
[](char character) -> bool { return character == '\0'; });
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice

auto sut = *iox2::container::StaticString<STRING_SIZE>::from_utf8("ABC");
ASSERT_TRUE(sut.unchecked_code_units().back_element());
sut.unchecked_code_units().back_element().value().get() = 'Z';
ASSERT_STREQ(sut.unchecked_access().c_str(), "ABZ");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add ASSERT_TRUE(free_space_is_all_zeroes(sut)); here, too.

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.

Shared memory compatible C++ string data type
3 participants