mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Merge remote-tracking branch 'Microsoft/master'
This commit is contained in:
commit
d5847ceef0
@ -75,7 +75,7 @@ constexpr byte& operator|=(byte& l, byte r) noexcept
|
|||||||
|
|
||||||
constexpr byte operator|(byte l, byte r) noexcept
|
constexpr byte operator|(byte l, byte r) noexcept
|
||||||
{
|
{
|
||||||
return byte(static_cast<unsigned char>(l) + static_cast<unsigned char>(r));
|
return byte(static_cast<unsigned char>(l) | static_cast<unsigned char>(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr byte& operator&=(byte& l, byte r) noexcept
|
constexpr byte& operator&=(byte& l, byte r) noexcept
|
||||||
|
@ -486,6 +486,16 @@ inline std::wstring to_string(wstring_span<> view)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
template <typename CharT,
|
||||||
|
typename Traits = typename std::char_traits<CharT>,
|
||||||
|
typename Allocator = std::allocator<CharT>,
|
||||||
|
typename gCharT,
|
||||||
|
std::ptrdiff_t Extent>
|
||||||
|
std::basic_string<CharT, Traits, Allocator> to_basic_string(basic_string_span<gCharT, Extent> view)
|
||||||
|
{
|
||||||
|
return {view.data(), static_cast<size_t>(view.length())};
|
||||||
|
}
|
||||||
|
|
||||||
// zero-terminated string span, used to convert
|
// zero-terminated string span, used to convert
|
||||||
// zero-terminated spans to legacy strings
|
// zero-terminated spans to legacy strings
|
||||||
template <typename CharT, std::ptrdiff_t Extent = dynamic_extent>
|
template <typename CharT, std::ptrdiff_t Extent = dynamic_extent>
|
||||||
|
@ -114,6 +114,18 @@ SUITE(string_span_tests)
|
|||||||
CHECK(s2.length() == 5);
|
CHECK(s2.length() == 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(TestToBasicString)
|
||||||
|
{
|
||||||
|
auto s = gsl::to_basic_string<char,std::char_traits<char>,::std::allocator<char>>(cstring_span<>{});
|
||||||
|
CHECK(s.length() == 0);
|
||||||
|
|
||||||
|
char stack_string[] = "Hello";
|
||||||
|
cstring_span<> v = ensure_z(stack_string);
|
||||||
|
auto s2 = gsl::to_basic_string<char,std::char_traits<char>,::std::allocator<char>>(v);
|
||||||
|
CHECK(static_cast<cstring_span<>::index_type>(s2.length()) == v.length());
|
||||||
|
CHECK(s2.length() == 5);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(EqualityAndImplicitConstructors)
|
TEST(EqualityAndImplicitConstructors)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user