From 82c93061cc6768eade222bf7dbe6682286ad6999 Mon Sep 17 00:00:00 2001 From: Teodor Andrei Vica Date: Sat, 25 Apr 2026 14:13:11 +0300 Subject: [PATCH 1/7] Update files to solve missing or incorrect beman::cstring_view declaration Signed-off-by: Teodor Andrei Vica --- .pre-commit-config.yaml | 3 ++- include/beman/cstring_view/cstring_view.hpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3ca4b09..285e7c7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,6 +43,7 @@ repos: - repo: https://github.com/bemanproject/beman-tidy rev: v0.3.1 hooks: - - id: beman-tidy + - id: beman-tidy + args: [".", "--verbose", "--require-all"] exclude: 'cookiecutter/|infra/' diff --git a/include/beman/cstring_view/cstring_view.hpp b/include/beman/cstring_view/cstring_view.hpp index 5454d98..6da9880 100644 --- a/include/beman/cstring_view/cstring_view.hpp +++ b/include/beman/cstring_view/cstring_view.hpp @@ -16,7 +16,7 @@ #include #include -namespace beman { +namespace beman::cstring_view { #if !defined(USE_CPP17_VARIANT) static_assert(__cpp_concepts >= 201907L); @@ -81,7 +81,7 @@ constexpr wcstring_view operator""_csv(const wchar_t* str, size_t len) noexcep #endif } // namespace cstring_view_literals } // namespace literals -} // namespace beman +} // namespace beman::cstring_view namespace beman { From 979831b9452fce0f355b0e138594b049fb90caad Mon Sep 17 00:00:00 2001 From: Teodor Andrei Vica Date: Sat, 25 Apr 2026 14:16:05 +0300 Subject: [PATCH 2/7] Solved final declaration for cstring_view namespace Signed-off-by: Teodor Andrei Vica --- include/beman/cstring_view/cstring_view.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/beman/cstring_view/cstring_view.hpp b/include/beman/cstring_view/cstring_view.hpp index 6da9880..85f6fd7 100644 --- a/include/beman/cstring_view/cstring_view.hpp +++ b/include/beman/cstring_view/cstring_view.hpp @@ -378,7 +378,7 @@ std::basic_ostream& operator<<(std::basic_ostream& return os << std::basic_string_view(str); } -} // namespace beman +} // namespace beman::cstring_view #if __cpp_lib_format >= 201907L // [format.formatter.spec] From b377c0da5cacd0a7c4dfe3ee42e21a5a15de2e3d Mon Sep 17 00:00:00 2001 From: Teodor Andrei Vica Date: Sat, 25 Apr 2026 14:55:29 +0300 Subject: [PATCH 3/7] updated namespace across the system Signed-off-by: Teodor Andrei Vica --- examples/example.cpp | 22 ++--- include/beman/cstring_view/cstring_view.hpp | 95 +++++++++++-------- .../beman/cstring_view/cstring_view.test.cpp | 10 +- 3 files changed, 72 insertions(+), 55 deletions(-) diff --git a/examples/example.cpp b/examples/example.cpp index a9a6efb..7256cac 100644 --- a/examples/example.cpp +++ b/examples/example.cpp @@ -7,7 +7,7 @@ #include using namespace std::literals; -using namespace beman::literals; +using namespace beman::cstring_view::literals; #if __cpp_lib_three_way_comparison std::string_view to_string(std::strong_ordering order) { @@ -27,10 +27,10 @@ std::string_view to_string(std::strong_ordering order) { #endif int main() { - std::string s = "hello world"; - beman::cstring_view z0 = "hello"; - beman::cstring_view z1 = s; - beman::cstring_view empty; + std::string s = "hello world"; + beman::cstring_view::cstring_view z0 = "hello"; + beman::cstring_view::cstring_view z1 = s; + beman::cstring_view::cstring_view empty; std::cout << z0 << "\n"; #if __cpp_lib_starts_ends_with >= 201711L std::cout << s.starts_with(z0) << "\n"; @@ -38,7 +38,7 @@ int main() { std::cout << z0.starts_with("hello") << "\n"; std::cout << z0.starts_with("hello"_csv) << "\n"; #endif - std::cout << std::hash{}(z1) << "\n"; + std::cout << std::hash{}(z1) << "\n"; std::cout << z1 << std::endl; std::cout << ("hello"_csv == "hello"sv) << "\n"; std::cout << ("hello"_csv == "hello"_csv) << "\n"; @@ -53,10 +53,10 @@ int main() { std::cout << "\"" << empty << "\"\n"; std::cout << (empty == ""_csv) << "\n"; - std::wstring ws = L"hello world"; - beman::wcstring_view wz0 = L"hello"; - beman::wcstring_view wz1 = ws; - beman::wcstring_view wempty; + std::wstring ws = L"hello world"; + beman::cstring_view::wcstring_view wz0 = L"hello"; + beman::cstring_view::wcstring_view wz1 = ws; + beman::cstring_view::wcstring_view wempty; #if __cpp_lib_format >= 201907L std::wcout << std::format(L"{}\n", wz0); #endif @@ -66,7 +66,7 @@ int main() { std::cout << wz0.starts_with(L"hello") << "\n"; std::cout << wz0.starts_with(L"hello"_csv) << "\n"; #endif - std::cout << std::hash{}(wz1) << "\n"; + std::cout << std::hash{}(wz1) << "\n"; std::wcout << wz1 << std::endl; std::cout << (L"hello"_csv == L"hello"sv) << "\n"; std::cout << (L"hello"_csv == L"hello"_csv) << "\n"; diff --git a/include/beman/cstring_view/cstring_view.hpp b/include/beman/cstring_view/cstring_view.hpp index 85f6fd7..4e2aed8 100644 --- a/include/beman/cstring_view/cstring_view.hpp +++ b/include/beman/cstring_view/cstring_view.hpp @@ -16,7 +16,8 @@ #include #include -namespace beman::cstring_view { +namespace beman { +namespace cstring_view { #if !defined(USE_CPP17_VARIANT) static_assert(__cpp_concepts >= 201907L); @@ -53,7 +54,10 @@ using u16cstring_view = basic_cstring_view; using u32cstring_view = basic_cstring_view; using wcstring_view = basic_cstring_view; -inline namespace literals { +} // namespace cstring_view +} // namespace beman + +namespace beman::cstring_view::literals { inline namespace cstring_view_literals { #ifndef _MSC_VER #pragma GCC diagnostic push @@ -67,23 +71,23 @@ inline namespace cstring_view_literals { #pragma warning(disable : 4455) #endif // [cstring.view.literals], suffix for basic_cstring_view literals -constexpr cstring_view operator""_csv(const char* str, size_t len) noexcept; +constexpr beman::cstring_view::cstring_view operator""_csv(const char* str, size_t len) noexcept; #if __cpp_char8_t >= 201811L -constexpr u8cstring_view operator""_csv(const char8_t* str, size_t len) noexcept; +constexpr beman::cstring_view::u8cstring_view operator""_csv(const char8_t* str, size_t len) noexcept; #endif -constexpr u16cstring_view operator""_csv(const char16_t* str, size_t len) noexcept; -constexpr u32cstring_view operator""_csv(const char32_t* str, size_t len) noexcept; -constexpr wcstring_view operator""_csv(const wchar_t* str, size_t len) noexcept; +constexpr beman::cstring_view::u16cstring_view operator""_csv(const char16_t* str, size_t len) noexcept; +constexpr beman::cstring_view::u32cstring_view operator""_csv(const char32_t* str, size_t len) noexcept; +constexpr beman::cstring_view::wcstring_view operator""_csv(const wchar_t* str, size_t len) noexcept; #ifndef _MSC_VER #pragma GCC diagnostic pop #else #pragma warning(pop) #endif } // namespace cstring_view_literals -} // namespace literals -} // namespace beman::cstring_view +} // namespace beman::cstring_view::literals namespace beman { +namespace cstring_view { template */> class basic_cstring_view { @@ -351,39 +355,42 @@ class basic_cstring_view { size_type size_; // exposition only }; -inline namespace literals { +template +std::basic_ostream& operator<<(std::basic_ostream& os, + basic_cstring_view str) { + return os << std::basic_string_view(str); +} + +} // namespace cstring_view +} // namespace beman + +namespace beman::cstring_view::literals { inline namespace cstring_view_literals { // [cstring.view.literals], suffix for basic_cstring_view literals -constexpr cstring_view operator""_csv(const char* str, size_t len) noexcept { return basic_cstring_view(str, len); } +constexpr beman::cstring_view::cstring_view operator""_csv(const char* str, size_t len) noexcept { + return beman::cstring_view::basic_cstring_view(str, len); +} #if __cpp_char8_t >= 201811L -constexpr u8cstring_view operator""_csv(const char8_t* str, size_t len) noexcept { - return basic_cstring_view(str, len); +constexpr beman::cstring_view::u8cstring_view operator""_csv(const char8_t* str, size_t len) noexcept { + return beman::cstring_view::basic_cstring_view(str, len); } #endif -constexpr u16cstring_view operator""_csv(const char16_t* str, size_t len) noexcept { - return basic_cstring_view(str, len); +constexpr beman::cstring_view::u16cstring_view operator""_csv(const char16_t* str, size_t len) noexcept { + return beman::cstring_view::basic_cstring_view(str, len); } -constexpr u32cstring_view operator""_csv(const char32_t* str, size_t len) noexcept { - return basic_cstring_view(str, len); +constexpr beman::cstring_view::u32cstring_view operator""_csv(const char32_t* str, size_t len) noexcept { + return beman::cstring_view::basic_cstring_view(str, len); } -constexpr wcstring_view operator""_csv(const wchar_t* str, size_t len) noexcept { - return basic_cstring_view(str, len); +constexpr beman::cstring_view::wcstring_view operator""_csv(const wchar_t* str, size_t len) noexcept { + return beman::cstring_view::basic_cstring_view(str, len); } } // namespace cstring_view_literals -} // namespace literals - -template -std::basic_ostream& operator<<(std::basic_ostream& os, - basic_cstring_view str) { - return os << std::basic_string_view(str); -} - -} // namespace beman::cstring_view +} // namespace beman::cstring_view::literals #if __cpp_lib_format >= 201907L // [format.formatter.spec] template -struct std::formatter, charT> { +struct std::formatter, charT> { formatter() = default; constexpr auto parse(basic_format_parse_context& context) { return sv_formatter.parse(context); } template @@ -398,26 +405,36 @@ struct std::formatter, charT> { // [cstring.view.hash], hash support template <> -struct std::hash { - auto operator()(const beman::cstring_view& sv) const noexcept { return std::hash{}(sv); } +struct std::hash { + auto operator()(const beman::cstring_view::cstring_view& sv) const noexcept { + return std::hash{}(sv); + } }; #if __cpp_char8_t >= 201811L template <> -struct std::hash { - auto operator()(const beman::u8cstring_view& sv) const noexcept { return std::hash{}(sv); } +struct std::hash { + auto operator()(const beman::cstring_view::u8cstring_view& sv) const noexcept { + return std::hash{}(sv); + } }; #endif template <> -struct std::hash { - auto operator()(const beman::u16cstring_view& sv) const noexcept { return std::hash{}(sv); } +struct std::hash { + auto operator()(const beman::cstring_view::u16cstring_view& sv) const noexcept { + return std::hash{}(sv); + } }; template <> -struct std::hash { - auto operator()(const beman::u32cstring_view& sv) const noexcept { return std::hash{}(sv); } +struct std::hash { + auto operator()(const beman::cstring_view::u32cstring_view& sv) const noexcept { + return std::hash{}(sv); + } }; template <> -struct std::hash { - auto operator()(const beman::wcstring_view& sv) const noexcept { return std::hash{}(sv); } +struct std::hash { + auto operator()(const beman::cstring_view::wcstring_view& sv) const noexcept { + return std::hash{}(sv); + } }; #endif // BEMAN_CSTRING_VIEW_CSTRING_VIEW_HPP diff --git a/tests/beman/cstring_view/cstring_view.test.cpp b/tests/beman/cstring_view/cstring_view.test.cpp index 7e48df3..193e03a 100644 --- a/tests/beman/cstring_view/cstring_view.test.cpp +++ b/tests/beman/cstring_view/cstring_view.test.cpp @@ -5,13 +5,13 @@ #include #include -using namespace beman::literals; +using namespace beman::cstring_view::literals; using namespace std::literals; TEST(StringView, ConstructionDestruction) { - std::string s = "hello"; - beman::cstring_view h1 = "hello"; - beman::cstring_view h2 = h1; + std::string s = "hello"; + beman::cstring_view::cstring_view h1 = "hello"; + beman::cstring_view::cstring_view h2 = h1; EXPECT_EQ(h1.c_str(), h2.c_str()); EXPECT_NE(h1.c_str(), s.c_str()); @@ -31,7 +31,7 @@ TEST(StringView, ConstructionDestruction) { auto first = h1.substr(0, 2); auto end = h1.substr(2); EXPECT_TRUE((std::is_same_v)); - EXPECT_TRUE((std::is_same_v)); + EXPECT_TRUE((std::is_same_v)); EXPECT_EQ(first, "he"); EXPECT_EQ(end, "llo"); } From 27153a01ebd479d189c1c6f79e0f2679d413a205 Mon Sep 17 00:00:00 2001 From: Teodor Andrei Vica Date: Sat, 25 Apr 2026 14:59:35 +0300 Subject: [PATCH 4/7] solved a bad namespace name Signed-off-by: Teodor Andrei Vica --- include/beman/cstring_view/cstring_view.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/beman/cstring_view/cstring_view.hpp b/include/beman/cstring_view/cstring_view.hpp index 4e2aed8..12bf3bb 100644 --- a/include/beman/cstring_view/cstring_view.hpp +++ b/include/beman/cstring_view/cstring_view.hpp @@ -394,7 +394,8 @@ struct std::formatter, ch formatter() = default; constexpr auto parse(basic_format_parse_context& context) { return sv_formatter.parse(context); } template - auto format(beman::basic_cstring_view csv, basic_format_context<_Out, charT>& context) const { + auto format(beman::cstring_view::basic_cstring_view csv, + basic_format_context<_Out, charT>& context) const { return sv_formatter.format(csv, context); } From a385a760c30d7ae6ab4d8b51a2dc0ec923adddde Mon Sep 17 00:00:00 2001 From: Teodor Andrei Vica Date: Sat, 25 Apr 2026 15:07:54 +0300 Subject: [PATCH 5/7] remove unnecessary changes --- .pre-commit-config.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 285e7c7..608bceb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,11 +39,4 @@ repos: hooks: - id: codespell - # Beman standard checking via beman-tidy: - - repo: https://github.com/bemanproject/beman-tidy - rev: v0.3.1 - hooks: - - id: beman-tidy - args: [".", "--verbose", "--require-all"] - exclude: 'cookiecutter/|infra/' From 3361207614be1342d5b3734cf26453d84496826e Mon Sep 17 00:00:00 2001 From: Teodor Andrei Vica Date: Sat, 25 Apr 2026 15:10:31 +0300 Subject: [PATCH 6/7] Revert "remove unnecessary changes" This reverts commit a385a760c30d7ae6ab4d8b51a2dc0ec923adddde. --- .pre-commit-config.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 608bceb..285e7c7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,4 +39,11 @@ repos: hooks: - id: codespell + # Beman standard checking via beman-tidy: + - repo: https://github.com/bemanproject/beman-tidy + rev: v0.3.1 + hooks: + - id: beman-tidy + args: [".", "--verbose", "--require-all"] + exclude: 'cookiecutter/|infra/' From 82af7d3f210be72f96f09fb36ea5170c4b25f200 Mon Sep 17 00:00:00 2001 From: Teodor Andrei Vica Date: Sat, 25 Apr 2026 15:34:11 +0300 Subject: [PATCH 7/7] updated README Signed-off-by: Teodor Andrei Vica --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 31b6c6f..6a127c3 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,8 @@ The following code snippet illustrates how we can use `cstring_view` to make a b #include #include +using namespace beman::cstring_view; + int main(int argc, const char** argv) { std::vector args(argv, argv+argc); }