Skip to content

Update cstring_view to latest exemplar#17

Merged
ednolan merged 1 commit intomainfrom
enolan_modernexemplar2
Mar 25, 2026
Merged

Update cstring_view to latest exemplar#17
ednolan merged 1 commit intomainfrom
enolan_modernexemplar2

Conversation

@ednolan
Copy link
Member

@ednolan ednolan commented Mar 25, 2026

  • Make cstring_view an INTERFACE-based library
  • Bring cstring_view the new JSON-based CI framework
  • Add some missing SPDX license identifiers
  • Update the README to contain the latest language and a compiler support table
  • Update the CMake installation logic to the latest version
  • Slightly adjust the implementation of the default constructor for C++20 compatibility

@ednolan ednolan mentioned this pull request Mar 25, 2026
{"preset": "msvc-release", "runner": "windows-latest"}
]

build-and-test:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This bumps minimum supported version to C++20. We support 17 already and want to build&test that, and I'll be seeing if we can bring it down to 14 or 11 in the future.

Also, this removes old compilers (GCC 12, Clang 17). We should definitely keep some of those if possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are free to add those after making changes, but I removed them based on testing that the builds with those jobs currently fail. The reasons are that the older compilers in question lack support for <format>; and that cstring_view uses std::type_identity_t which isn't in C++17.

cmake_minimum_required(VERSION 3.25)

set(CMAKE_CXX_STANDARD 23)
cmake_minimum_required(VERSION 3.30...4.3)
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there a reason for the upper bound?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not a CMake expert, but I'm told that this is a best practice having to do with better handling of CMake policy defaults.


* C++17
* CMake 3.25
* A C++ compiler that conforms to the C++20 standard or greater
Copy link
Collaborator

Choose a reason for hiding this comment

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

why c++20? We are explicitly trying to support c++17.

Copy link
Member Author

Choose a reason for hiding this comment

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

See above comment (the implementation currently uses std::type_identity_t).

static constexpr size_type npos = size_type(-1);

private:
static constexpr charT empty_string[1]{};
Copy link
Collaborator

Choose a reason for hiding this comment

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

unexpected change for an "update to latest version". Did the old code break some compiler?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. This is the compiler error I was working around:

In file included from /src/examples/example.cpp:3:
/src/include/beman/cstring_view/cstring_view.hpp: In constructor 'constexpr beman::basic_cstring_view<charT, traits>::basic_cstring_view()':
/src/include/beman/cstring_view/cstring_view.hpp:115:28: error: 'empty_string' defined 'static' in 'constexpr' function only available with '-std=c++2b' or '-std=gnu++2b'
  115 |         static const charT empty_string[1]{};
      |                            ^~~~~~~~~~~~

@@ -1 +0,0 @@
#include <beman/cstring_view/cstring_view.hpp>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please re-add this file; Lakos rule that each header has a cpp file that includes it that verifies it is standalone.

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't need a cpp file to do that test; see https://cmake.org/cmake/help/latest/prop_tgt/VERIFY_INTERFACE_HEADER_SETS.html, which takes care of this in beman.

@ednolan ednolan force-pushed the enolan_modernexemplar2 branch from c902c54 to 88286f5 Compare March 25, 2026 16:40
- Make cstring_view an INTERFACE-based library
- Bring cstring_view the new JSON-based CI framework
- Add some missing SPDX license identifiers
- Update the README to contain the latest language and a compiler support table
- Update the CMake installation logic to the latest version
- Slightly adjust the implementation of the default constructor for C++20 compatibility
@ednolan ednolan force-pushed the enolan_modernexemplar2 branch from 88286f5 to 80397d5 Compare March 25, 2026 16:44
@ednolan ednolan merged commit 38067f2 into main Mar 25, 2026
70 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.

2 participants