Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make zstring family don't require empty angle brackets any more #998

Merged
merged 1 commit into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ not_null | ☑ | restricts a pointer / smart po
span | ☑ | a view over a contiguous sequence of memory. Based on the standardized verison of `std::span`, however `gsl::span` enforces bounds checking. See the [wiki](https://github.com/microsoft/GSL/wiki/gsl::span-and-std::span) for additional information.
span_p | ☐ | spans a range starting from a pointer to the first place for which the predicate is true
basic_zstring | ☑ | A pointer to a C-string (zero-terminated array) with a templated char type
zstring | ☑ | An alias to `basic_zstring` with a char type of char
czstring | ☑ | An alias to `basic_zstring` with a char type of const char
wzstring | ☑ | An alias to `basic_zstring` with a char type of wchar_t
cwzstring | ☑ | An alias to `basic_zstring` with a char type of const wchar_t
u16zstring | ☑ | An alias to `basic_zstring` with a char type of char16_t
cu16zstring | ☑ | An alias to `basic_zstring` with a char type of const char16_t
u32zstring | ☑ | An alias to `basic_zstring` with a char type of char32_t
cu32zstring | ☑ | An alias to `basic_zstring` with a char type of const char32_t
zstring | ☑ | An alias to `basic_zstring` with dynamic extent and a char type of char
czstring | ☑ | An alias to `basic_zstring` with dynamic extent and a char type of const char
wzstring | ☑ | An alias to `basic_zstring` with dynamic extent and a char type of wchar_t
cwzstring | ☑ | An alias to `basic_zstring` with dynamic extent and a char type of const wchar_t
u16zstring | ☑ | An alias to `basic_zstring` with dynamic extent and a char type of char16_t
cu16zstring | ☑ | An alias to `basic_zstring` with dynamic extent and a char type of const char16_t
u32zstring | ☑ | An alias to `basic_zstring` with dynamic extent and a char type of char32_t
cu32zstring | ☑ | An alias to `basic_zstring` with dynamic extent and a char type of const char32_t
[**2. Owners**][cg-owners] | |
unique_ptr | ☑ | an alias to `std::unique_ptr`
shared_ptr | ☑ | an alias to `std::shared_ptr`
Expand Down
24 changes: 8 additions & 16 deletions include/gsl/string_span
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,21 @@ namespace gsl
template <typename CharT, std::size_t Extent = dynamic_extent>
using basic_zstring = CharT*;

template <std::size_t Extent = dynamic_extent>
using czstring = basic_zstring<const char, Extent>;
using czstring = basic_zstring<const char, dynamic_extent>;

template <std::size_t Extent = dynamic_extent>
using cwzstring = basic_zstring<const wchar_t, Extent>;
using cwzstring = basic_zstring<const wchar_t, dynamic_extent>;

template <std::size_t Extent = dynamic_extent>
using cu16zstring = basic_zstring<const char16_t, Extent>;
using cu16zstring = basic_zstring<const char16_t, dynamic_extent>;

template <std::size_t Extent = dynamic_extent>
using cu32zstring = basic_zstring<const char32_t, Extent>;
using cu32zstring = basic_zstring<const char32_t, dynamic_extent>;

template <std::size_t Extent = dynamic_extent>
using zstring = basic_zstring<char, Extent>;
using zstring = basic_zstring<char, dynamic_extent>;

template <std::size_t Extent = dynamic_extent>
using wzstring = basic_zstring<wchar_t, Extent>;
using wzstring = basic_zstring<wchar_t, dynamic_extent>;

template <std::size_t Extent = dynamic_extent>
using u16zstring = basic_zstring<char16_t, Extent>;
using u16zstring = basic_zstring<char16_t, dynamic_extent>;

template <std::size_t Extent = dynamic_extent>
using u32zstring = basic_zstring<char32_t, Extent>;
using u32zstring = basic_zstring<char32_t, dynamic_extent>;

namespace details
{
Expand Down
8 changes: 4 additions & 4 deletions tests/string_span_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ TEST(string_span_tests, zstring)
auto name = CreateTempName({buf, 10});
if (!name.empty())
{
czstring<> str = name.assume_z();
czstring str = name.assume_z();
EXPECT_TRUE(generic::strlen(str) == 3);
EXPECT_TRUE(*(str + 3) == '\0');
}
Expand Down Expand Up @@ -1028,7 +1028,7 @@ TEST(string_span_tests, wzstring)
const auto name = CreateTempNameW({buf, 10});
if (!name.empty())
{
cwzstring<> str = name.assume_z();
cwzstring str = name.assume_z();
EXPECT_TRUE(generic::strnlen(str, 10) == 3);
EXPECT_TRUE(*(str + 3) == L'\0');
}
Expand Down Expand Up @@ -1071,7 +1071,7 @@ TEST(string_span_tests, u16zstring)
const auto name = CreateTempNameU16({buf, 10});
if (!name.empty())
{
cu16zstring<> str = name.assume_z();
cu16zstring str = name.assume_z();
EXPECT_TRUE(generic::strnlen(str, 10) == 3);
EXPECT_TRUE(*(str + 3) == L'\0');
}
Expand Down Expand Up @@ -1114,7 +1114,7 @@ TEST(string_span_tests, u32zstring)
const auto name = CreateTempNameU32({buf, 10});
if (!name.empty())
{
cu32zstring<> str = name.assume_z();
cu32zstring str = name.assume_z();
EXPECT_TRUE(generic::strnlen(str, 10) == 3);
EXPECT_TRUE(*(str + 3) == L'\0');
}
Expand Down