Skip to content

Commit

Permalink
Merge pull request #135 from biojppm/fix/gtest
Browse files Browse the repository at this point in the history
  • Loading branch information
biojppm authored Apr 26, 2024
2 parents d0fde6f + a8aa092 commit 6a73831
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
33 changes: 17 additions & 16 deletions changelog/0.2.0.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
### Breaking changes
- [#PR101](https://github.com/biojppm/c4core/pull/101): As part of the `substr` ctor cleanup, the `to_substr(char (&arr)[N])` overload no longer decays to `char*` inside. This changes calling code by now returning a `substr` with length equal to `N-1` instead of `strlen(arr)` as before:
```c++
// longer than "foo", ie longer than {'f', 'o', 'o', '\0'}:
char arr[] = "foo\0\0\0\0\0\0";
assert(strlen(arr) == 3);
assert(sizeof(arr) == 9);

// previously:
assert(to_substr(arr).len == 3);
// now:
assert(to_substr(arr).len == 9);

// the breaking change happens only with arrays:
assert(to_substr((char*)ptr).len == 3); // as before
```
- [PR#111](https://github.com/biojppm/c4core/pull/111) - Rename formatting overloads accepting `c4::append`:
- `catrs(append_t, ...) -> catrs_append(...)`
- `catseprs(append_t, ...) -> catseprs_append(...)`
- `formatrs(append_t, ...) -> formatrs_append(...)`
- [#PR101](https://github.com/biojppm/c4core/pulls/101): As part of the `substr` ctor cleanup, the `to_substr(char (&arr)[N])` overload no longer decays to `char*` inside. This changes calling code by now returning a `substr` with length equal to `N-1` instead of `strlen(arr)` as before:
```c++
// longer than "foo", ie longer than {'f', 'o', 'o', '\0'}:
char arr[] = "foo\0\0\0\0\0\0";
assert(strlen(arr) == 3);
assert(sizeof(arr) == 9);

// previously:
assert(to_substr(arr).len == 3);
// now:
assert(to_substr(arr).len == 9);
// the breaking change happens only with arrays:
assert(to_substr((char*)ptr).len == 3); // as before
```
### New features
- [#PR101](https://github.com/biojppm/c4core/pulls/101): For `substr` and `csubstr`:
- [#PR101](https://github.com/biojppm/c4core/pull/101): For `substr` and `csubstr`:
- add simultaneous ctors from `char[]` and `char*`. Using SFINAE to narrow the `char*` overload prevents it from overriding the `char[]` overload. Thanks to @huangqinjin for the idea (see [#97](https://github.com/biojppm/c4core/issues/97)).
- remove unneeded constructors of `csubstr` from non-const chars.
- to each single-argument ctor, add corresponding functions `to_csubstr()` and `to_substr()` to enable clients coercing their types in generic code such as `c4::cat()` and `c4::format()`.
- Add interop with `std::string_view` when the standard is at least C++17 ([#PR101](https://github.com/biojppm/c4core/pulls/101)):
- Add interop with `std::string_view` when the standard is at least C++17 ([#PR101](https://github.com/biojppm/c4core/pull/101)):
- provided in the header [`c4/std/string_view.hpp`](src/c4/std/string_view.hpp)
- similarly to existing interop headers, this is opt-in and requires explicit inclusion
- implemented:
Expand Down Expand Up @@ -73,5 +73,6 @@ assert(to_substr((char*)ptr).len == 3); // as before
### Thanks
- @huangqinjin
- @zangruochen
- @yrHeTaTeJlb
2 changes: 1 addition & 1 deletion cmake
Submodule cmake updated 1 files
+14 −6 c4Project.cmake

0 comments on commit 6a73831

Please sign in to comment.