mirror of
https://github.com/microsoft/GSL.git
synced 2025-03-26 14:58:31 -04:00
ran clang-format over string_span
This commit is contained in:
parent
a64c489c78
commit
7721de88f3
@ -57,36 +57,55 @@ namespace gsl
|
|||||||
//
|
//
|
||||||
|
|
||||||
template <typename CharT, std::size_t Extent = dynamic_extent>
|
template <typename CharT, std::size_t Extent = dynamic_extent>
|
||||||
using basic_zstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = CharT*;
|
using basic_zstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] = CharT*;
|
||||||
|
|
||||||
template <std::size_t Extent = dynamic_extent>
|
template <std::size_t Extent = dynamic_extent>
|
||||||
using czstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_zstring<const char, Extent>;
|
using czstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_zstring<const char, Extent>;
|
||||||
|
|
||||||
template <std::size_t Extent = dynamic_extent>
|
template <std::size_t Extent = dynamic_extent>
|
||||||
using cwzstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_zstring<const wchar_t, Extent>;
|
using cwzstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_zstring<const wchar_t, Extent>;
|
||||||
|
|
||||||
template <std::size_t Extent = dynamic_extent>
|
template <std::size_t Extent = dynamic_extent>
|
||||||
using cu16zstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_zstring<const char16_t, Extent>;
|
using cu16zstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_zstring<const char16_t, Extent>;
|
||||||
|
|
||||||
template <std::size_t Extent = dynamic_extent>
|
template <std::size_t Extent = dynamic_extent>
|
||||||
using cu32zstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_zstring<const char32_t, Extent>;
|
using cu32zstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_zstring<const char32_t, Extent>;
|
||||||
|
|
||||||
template <std::size_t Extent = dynamic_extent>
|
template <std::size_t Extent = dynamic_extent>
|
||||||
using zstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_zstring<char, Extent>;
|
using zstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_zstring<char, Extent>;
|
||||||
|
|
||||||
template <std::size_t Extent = dynamic_extent>
|
template <std::size_t Extent = dynamic_extent>
|
||||||
using wzstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_zstring<wchar_t, Extent>;
|
using wzstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_zstring<wchar_t, Extent>;
|
||||||
|
|
||||||
template <std::size_t Extent = dynamic_extent>
|
template <std::size_t Extent = dynamic_extent>
|
||||||
using u16zstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_zstring<char16_t, Extent>;
|
using u16zstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_zstring<char16_t, Extent>;
|
||||||
|
|
||||||
template <std::size_t Extent = dynamic_extent>
|
template <std::size_t Extent = dynamic_extent>
|
||||||
using u32zstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_zstring<char32_t, Extent>;
|
using u32zstring [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_zstring<char32_t, Extent>;
|
||||||
|
|
||||||
namespace details
|
namespace details
|
||||||
{
|
{
|
||||||
template <class CharT>
|
template <class CharT>
|
||||||
[[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] constexpr std::size_t string_length(const CharT* str, std::size_t n)
|
[[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see "
|
||||||
|
"isocpp/CppCoreGuidelines PR#1680")]] constexpr std::size_t
|
||||||
|
string_length(const CharT* str, std::size_t n)
|
||||||
{
|
{
|
||||||
if (str == nullptr || n == dynamic_extent) return 0;
|
if (str == nullptr || n == dynamic_extent) return 0;
|
||||||
|
|
||||||
@ -108,8 +127,9 @@ namespace details
|
|||||||
// Will fail-fast if sentinel cannot be found before max elements are examined.
|
// Will fail-fast if sentinel cannot be found before max elements are examined.
|
||||||
//
|
//
|
||||||
template <typename T, const T Sentinel>
|
template <typename T, const T Sentinel>
|
||||||
[[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]]constexpr span<T, dynamic_extent> ensure_sentinel(T* seq,
|
[[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see "
|
||||||
std::size_t max = static_cast<std::size_t>(-1))
|
"isocpp/CppCoreGuidelines PR#1680")]] constexpr span<T, dynamic_extent>
|
||||||
|
ensure_sentinel(T* seq, std::size_t max = static_cast<std::size_t>(-1))
|
||||||
{
|
{
|
||||||
Ensures(seq != nullptr);
|
Ensures(seq != nullptr);
|
||||||
|
|
||||||
@ -125,12 +145,13 @@ template <typename T, const T Sentinel>
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// ensure_z - creates a span for a zero terminated strings. The span will not contain the zero termination.
|
// ensure_z - creates a span for a zero terminated strings. The span will not contain the zero
|
||||||
// Will fail fast if a null-terminator cannot be found before the limit of size_type.
|
// termination. Will fail fast if a null-terminator cannot be found before the limit of size_type.
|
||||||
//
|
//
|
||||||
template <typename CharT>
|
template <typename CharT>
|
||||||
[[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] constexpr span<CharT, dynamic_extent> ensure_z(CharT* const& sz,
|
[[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see "
|
||||||
std::size_t max = static_cast<std::size_t>(-1))
|
"isocpp/CppCoreGuidelines PR#1680")]] constexpr span<CharT, dynamic_extent>
|
||||||
|
ensure_z(CharT* const& sz, std::size_t max = static_cast<std::size_t>(-1))
|
||||||
{
|
{
|
||||||
return ensure_sentinel<CharT, CharT(0)>(sz, max);
|
return ensure_sentinel<CharT, CharT(0)>(sz, max);
|
||||||
}
|
}
|
||||||
@ -142,37 +163,45 @@ constexpr span<CharT, dynamic_extent> ensure_z(CharT (&sz)[N])
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class Cont>
|
template <class Cont>
|
||||||
[[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] constexpr span<typename std::remove_pointer<typename Cont::pointer>::type, dynamic_extent> ensure_z(Cont& cont)
|
[[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see "
|
||||||
|
"isocpp/CppCoreGuidelines PR#1680")]] constexpr span<
|
||||||
|
typename std::remove_pointer<typename Cont::pointer>::type, dynamic_extent>
|
||||||
|
ensure_z(Cont& cont)
|
||||||
{
|
{
|
||||||
return ensure_z(cont.data(), cont.size());
|
return ensure_z(cont.data(), cont.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename CharT, std::size_t>
|
template <typename CharT, std::size_t>
|
||||||
class [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] basic_string_span;
|
class [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, "
|
||||||
|
"see isocpp/CppCoreGuidelines PR#1680")]] basic_string_span;
|
||||||
|
|
||||||
namespace details
|
namespace details
|
||||||
{
|
{
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] is_basic_string_span_oracle : std::false_type
|
struct [
|
||||||
{
|
[deprecated("string_span was removed from the C++ Core Guidelines. For more information, "
|
||||||
};
|
"see isocpp/CppCoreGuidelines PR#1680")]] is_basic_string_span_oracle
|
||||||
|
: std::false_type{};
|
||||||
|
|
||||||
template <typename CharT, std::size_t Extent>
|
template <typename CharT, std::size_t Extent>
|
||||||
struct [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] is_basic_string_span_oracle<basic_string_span<CharT, Extent>> : std::true_type
|
struct [[deprecated(
|
||||||
{
|
"string_span was removed from the C++ Core Guidelines. For more information, see "
|
||||||
};
|
"isocpp/CppCoreGuidelines PR#1680")]] is_basic_string_span_oracle<basic_string_span<CharT,
|
||||||
|
Extent>>
|
||||||
|
: std::true_type{};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] is_basic_string_span : is_basic_string_span_oracle<std::remove_cv_t<T>>
|
struct [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
{
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] is_basic_string_span
|
||||||
};
|
: is_basic_string_span_oracle<std::remove_cv_t<T>>{};
|
||||||
} // namespace details
|
} // namespace details
|
||||||
|
|
||||||
//
|
//
|
||||||
// string_span and relatives
|
// string_span and relatives
|
||||||
//
|
//
|
||||||
template <typename CharT, std::size_t Extent = dynamic_extent>
|
template <typename CharT, std::size_t Extent = dynamic_extent>
|
||||||
class [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] basic_string_span
|
class [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, "
|
||||||
|
"see isocpp/CppCoreGuidelines PR#1680")]] basic_string_span
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using element_type = CharT;
|
using element_type = CharT;
|
||||||
@ -280,8 +309,8 @@ public:
|
|||||||
return {span_.template subspan<Offset, Count>()};
|
return {span_.template subspan<Offset, Count>()};
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr basic_string_span<element_type, dynamic_extent>
|
constexpr basic_string_span<element_type, dynamic_extent> subspan(
|
||||||
subspan(size_type offset, size_type count = dynamic_extent) const
|
size_type offset, size_type count = dynamic_extent) const
|
||||||
{
|
{
|
||||||
return {span_.subspan(offset, count)};
|
return {span_.subspan(offset, count)};
|
||||||
}
|
}
|
||||||
@ -319,28 +348,44 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <std::size_t Extent = dynamic_extent>
|
template <std::size_t Extent = dynamic_extent>
|
||||||
using string_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_string_span<char, Extent>;
|
using string_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_string_span<char, Extent>;
|
||||||
|
|
||||||
template <std::size_t Extent = dynamic_extent>
|
template <std::size_t Extent = dynamic_extent>
|
||||||
using cstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_string_span<const char, Extent>;
|
using cstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_string_span<const char, Extent>;
|
||||||
|
|
||||||
template <std::size_t Extent = dynamic_extent>
|
template <std::size_t Extent = dynamic_extent>
|
||||||
using wstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_string_span<wchar_t, Extent>;
|
using wstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_string_span<wchar_t, Extent>;
|
||||||
|
|
||||||
template <std::size_t Extent = dynamic_extent>
|
template <std::size_t Extent = dynamic_extent>
|
||||||
using cwstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_string_span<const wchar_t, Extent>;
|
using cwstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_string_span<const wchar_t, Extent>;
|
||||||
|
|
||||||
template <std::size_t Extent = dynamic_extent>
|
template <std::size_t Extent = dynamic_extent>
|
||||||
using u16string_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_string_span<char16_t, Extent>;
|
using u16string_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_string_span<char16_t, Extent>;
|
||||||
|
|
||||||
template <std::size_t Extent = dynamic_extent>
|
template <std::size_t Extent = dynamic_extent>
|
||||||
using cu16string_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_string_span<const char16_t, Extent>;
|
using cu16string_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_string_span<const char16_t, Extent>;
|
||||||
|
|
||||||
template <std::size_t Extent = dynamic_extent>
|
template <std::size_t Extent = dynamic_extent>
|
||||||
using u32string_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_string_span<char32_t, Extent>;
|
using u32string_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_string_span<char32_t, Extent>;
|
||||||
|
|
||||||
template <std::size_t Extent = dynamic_extent>
|
template <std::size_t Extent = dynamic_extent>
|
||||||
using cu32string_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_string_span<const char32_t, Extent>;
|
using cu32string_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_string_span<const char32_t, Extent>;
|
||||||
|
|
||||||
//
|
//
|
||||||
// to_string() allow (explicit) conversions from string_span to string
|
// to_string() allow (explicit) conversions from string_span to string
|
||||||
@ -381,7 +426,8 @@ as_writable_bytes(basic_string_span<ElementType, Extent> s) noexcept
|
|||||||
// 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::size_t Extent = dynamic_extent>
|
template <typename CharT, std::size_t Extent = dynamic_extent>
|
||||||
class [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] basic_zstring_span
|
class [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, "
|
||||||
|
"see isocpp/CppCoreGuidelines PR#1680")]] basic_zstring_span
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using value_type = CharT;
|
using value_type = CharT;
|
||||||
@ -430,28 +476,44 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <std::size_t Max = dynamic_extent>
|
template <std::size_t Max = dynamic_extent>
|
||||||
using zstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_zstring_span<char, Max>;
|
using zstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_zstring_span<char, Max>;
|
||||||
|
|
||||||
template <std::size_t Max = dynamic_extent>
|
template <std::size_t Max = dynamic_extent>
|
||||||
using wzstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_zstring_span<wchar_t, Max>;
|
using wzstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_zstring_span<wchar_t, Max>;
|
||||||
|
|
||||||
template <std::size_t Max = dynamic_extent>
|
template <std::size_t Max = dynamic_extent>
|
||||||
using u16zstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_zstring_span<char16_t, Max>;
|
using u16zstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_zstring_span<char16_t, Max>;
|
||||||
|
|
||||||
template <std::size_t Max = dynamic_extent>
|
template <std::size_t Max = dynamic_extent>
|
||||||
using u32zstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_zstring_span<char32_t, Max>;
|
using u32zstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_zstring_span<char32_t, Max>;
|
||||||
|
|
||||||
template <std::size_t Max = dynamic_extent>
|
template <std::size_t Max = dynamic_extent>
|
||||||
using czstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_zstring_span<const char, Max>;
|
using czstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_zstring_span<const char, Max>;
|
||||||
|
|
||||||
template <std::size_t Max = dynamic_extent>
|
template <std::size_t Max = dynamic_extent>
|
||||||
using cwzstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_zstring_span<const wchar_t, Max>;
|
using cwzstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more "
|
||||||
|
"information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_zstring_span<const wchar_t, Max>;
|
||||||
|
|
||||||
template <std::size_t Max = dynamic_extent>
|
template <std::size_t Max = dynamic_extent>
|
||||||
using cu16zstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_zstring_span<const char16_t, Max>;
|
using cu16zstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For "
|
||||||
|
"more information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_zstring_span<const char16_t, Max>;
|
||||||
|
|
||||||
template <std::size_t Max = dynamic_extent>
|
template <std::size_t Max = dynamic_extent>
|
||||||
using cu32zstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For more information, see isocpp/CppCoreGuidelines PR#1680")]] = basic_zstring_span<const char32_t, Max>;
|
using cu32zstring_span [[deprecated("string_span was removed from the C++ Core Guidelines. For "
|
||||||
|
"more information, see isocpp/CppCoreGuidelines PR#1680")]] =
|
||||||
|
basic_zstring_span<const char32_t, Max>;
|
||||||
|
|
||||||
// operator ==
|
// operator ==
|
||||||
template <class CharT, std::size_t Extent, class T,
|
template <class CharT, std::size_t Extent, class T,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user