winrt:: hstring 结构 (c + +/WinRT) winrt::hstring struct (C++/WinRT)

表示文本字符串的 UTF-16 Unicode 字符的有序集合。A sequential collection of UTF-16 Unicode characters representing a text string. 有关 winrt:: hstring的更多示例和信息,请参阅 c + +/WinRT 中的字符串处理For more examples and info about winrt::hstring, see String handling in C++/WinRT. Winrt:: hstring类型会将hstring封装到类似于std:: wstring的接口后面。The winrt::hstring type encapsulates HSTRING behind an interface similar to that of std::wstring. HSTRING是 Windows 运行时字符串的句柄。A HSTRING is a handle to a Windows Runtime string.

语法Syntax

struct hstring

要求Requirements

支持的最低 SDK: Windows SDK 版本 10.0.17134.0 (Windows 10 版本 1803) Minimum supported SDK: Windows SDK version 10.0.17134.0 (Windows 10, version 1803)

命名空间: winrtNamespace: winrt

标头 % WindowsSdkDir% 包括 <WindowsTargetPlatformVersion> 默认情况下包含的 \cppwinrt\winrt\base.h () Header %WindowsSdkDir%Include<WindowsTargetPlatformVersion>\cppwinrt\winrt\base.h (included by default)

成员类型别名Member type aliases

别名名称Alias name 类型Type
hstring:: value_typehstring::value_type Wchar_t的同义词。A synonym for wchar_t.
hstring:: size_typehstring::size_type Uint32_t的同义词。A synonym for uint32_t.
hstring:: const_referencehstring::const_reference Hstring:: value_type const& 的同义词。A synonym for hstring::value_type const&.
hstring:: const_pointerhstring::const_pointer **Hstring:: value_type const * **的同义词。A synonym for hstring::value_type const*.
hstring:: const_iteratorhstring::const_iterator Hstring:: const_pointer的同义词。A synonym for hstring::const_pointer.
hstring:: const_reverse_iteratorhstring::const_reverse_iterator **Std:: reverse_iterator <hstring::const_iterator> **的同义词。A synonym for std::reverse_iterator<hstring::const_iterator>.

构造函数Constructors

构造函数Constructor 说明Description
hstring:: hstring 构造函数hstring::hstring constructor 使用输入字符串数据的副本初始化 hstring 结构的新实例。Initializes a new instance of the hstring struct with a copy of the input string data.

成员函数Member functions

函数Function 说明Description
hstring:: back 函数hstring::back function 返回对 hstring 对象中最后一个字符的引用。Returns a reference to the last character in the hstring object.
hstring:: begin 函数hstring::begin function 返回 hstring 对象中第一个字符的常量迭代器。Returns a const iterator to the first character in the hstring object.
hstring:: c_str 函数hstring::c_str function 返回一个指针,该指针指向 hstring 对象中的字符的以 null 结尾的 C 样式字符串;不进行复制。Returns a pointer to the underlying null-terminated C-style string of the characters in the hstring object; no copy is made.
hstring:: cbegin 函数hstring::cbegin function 返回 hstring 对象中第一个字符的常量迭代器。Returns a const iterator to the first character in the hstring object.
hstring:: cend 函数hstring::cend function 返回一个常量迭代器,该迭代器指向超出 hstring 对象) 中最后一个字符 (末尾的一个。Returns a const iterator to one beyond the end of (one beyond the last character in) the hstring object.
hstring:: clear 函数hstring::clear function 使 hstring 对象为空。Makes the hstring object empty.
hstring:: crbegin 函数hstring::crbegin function 返回一个常量反向迭代器,该迭代器指向超出 hstring 对象) 中最后一个字符 (末尾的一个。Returns a const reverse iterator to one beyond the end of (one beyond the last character in) the hstring object.
hstring:: crend 函数hstring::crend function 返回 hstring 对象中第一个字符的常量反向迭代器。Returns a const reverse iterator to the first character in the hstring object.
hstring::d ata 函数hstring::data function 返回 hstring 对象中字符的以 null 结尾的 C 样式字符串版本。Returns a null-terminated C-style string version of the characters in the hstring object.
hstring:: empty 函数hstring::empty function 返回一个值,该值指示 hstring 对象是否为空。Returns a value indicating whether the hstring object is empty.
hstring:: end 函数hstring::end function 返回一个常量迭代器,该迭代器指向超出 hstring 对象) 中最后一个字符 (末尾的一个。Returns a const iterator to one beyond the end of (one beyond the last character in) the hstring object.
hstring:: front 函数hstring::front function 返回对 hstring 对象中第一个字符的引用。Returns a reference to the first character in the hstring object.
hstring:: rbegin 函数hstring::rbegin function 返回一个常量反向迭代器,该迭代器指向超出 hstring 对象) 中最后一个字符 (末尾的一个。Returns a const reverse iterator to one beyond the end of (one beyond the last character in) the hstring object.
hstring:: rend 函数hstring::rend function 返回 hstring 对象中第一个字符的常量反向迭代器。Returns a const reverse iterator to the first character in the hstring object.
hstring:: size 函数hstring::size function 返回 hstring 对象中的字符数。Returns the number of characters in the hstring object.

成员运算符Member operators

运算符Operator 说明Description
hstring:: operator std:: wstring_viewhstring::operator std::wstring_view hstring 对象转换为 std:: wstring_viewConverts the hstring object to a std::wstring_view.
hstring:: operator [] ( 下标运算符) ) hstring::operator[] (subscript operator)) 返回对 hstring 对象内指定位置的字符的引用。Returns a reference to the character at the specified position within the hstring object.
hstring:: operator = (赋值运算符) hstring::operator= (assignment operator) hstring 对象赋值。Assigns a value to the hstring object.

Free 函数Free functions

函数Function 说明Description
attach_abi 函数attach_abi function hstring 对象附加到 Windows 运行时字符串的句柄。Attaches a hstring object to a handle to a Windows Runtime string.
copy_from_abi 函数copy_from_abi function 将句柄中的 hstring 对象复制到 Windows 运行时字符串的句柄。Copies to a hstring object from a handle to a Windows Runtime string. 清除 hstring,复制参数,并开始管理句柄。Clears the hstring, copies the parameter, and begins managing the handle.
copy_to_abi 函数copy_to_abi function hstring 对象复制到 Windows 运行时字符串的句柄。Copies to a handle to a Windows Runtime string from a hstring object.
detach_abi 函数detach_abi function hstring 对象的句柄分离,可能会将其返回给调用方。Detaches a hstring object from its handle, perhaps to return it to a caller.
to_hstring 函数to_hstring function 将输入值转换为 winrt:: hstring ,其中包含值的字符串表示形式。Converts an input value to a winrt::hstring containing the value's string representation.

免费运算符Free operators

运算符Operator 说明Description
operator! = (不相等运算符) operator!= (inequality operator) 返回一个值,该值指示两个参数是否不相等。Returns a value indicating whether the two parameters are unequal to one another.
operator + (串联运算符) operator+ (concatenation operator) 返回一个新的 hstring 对象,这是因为将两个参数连接在一起。Returns a new hstring object resulting from concatenating the two parameters together.
运算符< (小于运算符) operator< (less-than operator) 返回一个值,该值指示第一个参数是否小于第二个参数。Returns a value indicating whether the first parameter is less than the second parameter.
运算符<= (小于或等于运算符) operator<= (less-than-or-equal-to operator) 返回一个值,该值指示第一个参数是否小于或等于第二个参数。Returns a value indicating whether the first parameter is less than or equal to the second parameter.
operator = = (相等运算符) operator== (equality operator) 返回一个值,该值指示两个参数是否相等。Returns a value indicating whether the two parameters are equal to one another.
运算符> (大于运算符) operator> (greater-than operator) 返回一个值,该值指示第一个参数是否大于第二个参数。Returns a value indicating whether the first parameter is greater than the second parameter.
运算符>= (大于或等于运算符) operator>= (greater-than-or-equal-to operator) 返回一个值,该值指示第一个参数是否大于或等于第二个参数。Returns a value indicating whether the first parameter is greater than or equal to the second parameter.

迭代器Iterators

Hstring是一个范围,该范围由hstring:: beginhstring:: end成员函数定义,其中每个函数均返回常量迭代器 (如hstring:: cbeginhstring:: cend) 。An hstring is a range, and that range is defined by the hstring::begin and hstring::end member functions, each of which returns a const iterator (as do hstring::cbegin and hstring::cend). 因此,可以使用基于范围的hstring for 语句或std:: for_each模板函数枚举 hstring 对象中的字符。Because of this, you can enumerate the characters in an hstring object with either a range-based for statement, or with the std::for_each template function.

#include <iostream>
using namespace winrt;
...
void Iterators(hstring const& theHstring)
{
    for (auto const& element : theHstring)
    {
        std::wcout << element;
    }

    std::for_each(theHstring.cbegin(), theHstring.cend(), [](T const& element) { std::wcout << element; });
}

hstring:: hstring 构造函数hstring::hstring constructor

使用输入字符串数据的副本初始化 hstring 结构的新实例。Initializes a new instance of the hstring struct with a copy of the input string data.

语法Syntax

hstring() noexcept;
hstring(winrt::hstring const& h);
explicit hstring(std::wstring_view const& v);
hstring(std::wchar_t const* c);
hstring(std::wchar_t const* c, uint32_t s);

参数Parameters

h用于初始化hstring对象的hstring值。h An hstring value that initializes the hstring object.

v用于初始化hstring对象的std:: wstring_view值。v A std::wstring_view value that initializes the hstring object.

c指向用于初始化hstring对象的常量wchar_t的数组的指针。c A pointer to an array of constant wchar_t that initializes the hstring object.

s 一个数字,它指定 hstring 对象的固定大小。s A number that specifies a fixed size for the hstring object.

示例Example

using namespace winrt;
...
void Constructors(
    hstring const& theHstring,
    std::wstring_view const& theWstringView,
    wchar_t const* wideLiteral,
    std::wstring const& wideString)
{
    // hstring() noexcept
    hstring fromDefault{};

    // hstring(hstring const& h)
    hstring fromHstring{ theHstring };

    // explicit hstring(std::wstring_view const& value)
    hstring fromWstringView{ theWstringView };

    // hstring(wchar_t const* value)
    hstring fromWideLiteral{ wideLiteral };
    hstring fromWideString{ wideString.c_str() };

    // hstring(wchar_t const* value, uint32_t size)
    hstring fromWideLiteralWithSize{ wideLiteral, 256 };
    hstring fromWideStringWithSize{ wideString.c_str(), 256 };
}

hstring:: back 函数hstring::back function

返回对 hstring 对象中最后一个字符的引用。Returns a reference to the last character in the hstring object.

语法Syntax

std::wchar_t const& back() const noexcept;

返回值Return value

hstring 对象中最后一个字符的引用。A reference to the last character in the hstring object.

hstring:: begin 函数hstring::begin function

返回 hstring 对象中第一个字符的常量迭代器。Returns a const iterator to the first character in the hstring object. 请参阅 迭代器。See Iterators.

语法Syntax

std::wchar_t const* begin() const noexcept;

返回值Return value

Hstring对象中第一个字符的常量迭代器。A const iterator to the first character in the hstring object.

hstring:: c_str 函数hstring::c_str function

返回一个指针,该指针指向 hstring 对象中的字符的以 null 结尾的 C 样式字符串;不进行复制。Returns a pointer to the underlying null-terminated C-style string of the characters in the hstring object; no copy is made.

语法Syntax

std::wchar_t const* c_str() const noexcept;

返回值Return value

一个指针,它指向 hstring 对象中字符的以 null 结尾的基础的 C 样式字符串;不进行复制。A pointer to the underlying null-terminated C-style string of the characters in the hstring object; no copy is made.

示例Example

#include <iostream>
using namespace winrt;
...
void PrintHstring(hstring const& theHstring)
{
    // You can get a standard wide string from an hstring.
    std::wcout << theHstring.c_str() << std::endl;
}

hstring:: cbegin 函数hstring::cbegin function

返回 hstring 对象中第一个字符的常量迭代器。Returns a const iterator to the first character in the hstring object. 请参阅 迭代器。See Iterators.

语法Syntax

std::wchar_t const* cbegin() const noexcept;

返回值Return value

Hstring对象中第一个字符的常量迭代器。A const iterator to the first character in the hstring object.

hstring:: cend 函数hstring::cend function

返回一个常量迭代器,该迭代器指向超出 hstring 对象) 中最后一个字符 (末尾的一个。Returns a const iterator to one beyond the end of (one beyond the last character in) the hstring object. 请参阅 迭代器。See Iterators.

语法Syntax

std::wchar_t const* cend() const noexcept;

返回值Return value

一个常量迭代器,指向超出 hstring 对象) 中最后一个字符 (末尾以外的一个。A const iterator to one beyond the end of (one beyond the last character in) the hstring object.

hstring:: clear 函数hstring::clear function

使 hstring 对象为空。Makes the hstring object empty.

语法Syntax

void clear() noexcept;

hstring:: crbegin 函数hstring::crbegin function

返回一个常量反向迭代器,该迭代器指向超出 hstring 对象) 中最后一个字符 (末尾的一个。Returns a const reverse iterator to one beyond the end of (one beyond the last character in) the hstring object.

语法Syntax

std::reverse_iterator<std::wchar_t const*> crbegin() const noexcept;

返回值Return value

一个常数反向迭代器,到超出 hstring 对象) 中最后一个字符 (末尾之外的一个。A const reverse iterator to one beyond the end of (one beyond the last character in) the hstring object.

hstring:: crend 函数hstring::crend function

返回 hstring 对象中第一个字符的常量反向迭代器。Returns a const reverse iterator to the first character in the hstring object.

语法Syntax

std::reverse_iterator<std::wchar_t const*> crend() const noexcept;

返回值Return value

Hstring对象中的第一个字符的常量反向迭代器。A const reverse iterator to the first character in the hstring object.

hstring::d ata 函数hstring::data function

返回 hstring 对象中字符的以 null 结尾的 C 样式字符串版本。Returns a null-terminated C-style string version of the characters in the hstring object.

语法Syntax

std::wchar_t const* data() const noexcept;

返回值Return value

Hstring对象中的字符的以 null 结尾的 C 样式字符串版本。A null-terminated C-style string version of the characters in the hstring object.

示例Example

#include <iostream>
using namespace winrt;
...
void PrintHstring(hstring const& theHstring)
{
    // You can get a standard wide string from an hstring.
    std::wcout << theHstring.data() << std::endl;
}

hstring:: empty 函数hstring::empty function

返回一个值,该值指示 hstring 对象是否为空。Returns a value indicating whether the hstring object is empty.

语法Syntax

bool empty() const noexcept;

返回值Return value

true 如果 hstring 对象为空,则为; 否则为 falsetrue if the hstring object is empty, otherwise false.

hstring:: end 函数hstring::end function

返回一个常量迭代器,该迭代器指向超出 hstring 对象) 中最后一个字符 (末尾的一个。Returns a const iterator to one beyond the end of (one beyond the last character in) the hstring object. 请参阅 迭代器。See Iterators.

语法Syntax

std::wchar_t const* end() const noexcept;

返回值Return value

一个常量迭代器,指向超出 hstring 对象) 中最后一个字符 (末尾以外的一个。A const iterator to one beyond the end of (one beyond the last character in) the hstring object.

hstring:: front 函数hstring::front function

返回对 hstring 对象中第一个字符的引用。Returns a reference to the first character in the hstring object.

语法Syntax

std::wchar_t const& front() const noexcept;

返回值Return value

hstring 对象中第一个字符的引用。A reference to the first character in the hstring object.

hstring:: operator std:: wstring_viewhstring::operator std::wstring_view

hstring 对象转换为 std:: wstring_viewConverts the hstring object to a std::wstring_view.

语法Syntax

operator std::wstring_view() const noexcept;

返回值Return value

转换为std:: wstring_viewhstring对象。The hstring object converted to a std::wstring_view.

示例Example

using namespace winrt;
...
    Uri contosoUri{ L"https://www.contoso.com" };
    Uri awUri{ L"https://www.adventure-works.com" };

    // Uri::Domain() is of type hstring. But we can use hstring's conversion operator to std::wstring_view.
    std::wstring domainWstring{ contosoUri.Domain() }; // L"contoso.com"
    domainWstring = awUri.Domain(); // L"https://www.adventure-works.com"

hstring:: operator [] ( 下标运算符) hstring::operator[] (subscript operator)

返回对 hstring 对象内指定位置的字符的引用。Returns a reference to the character at the specified position within the hstring object.

语法Syntax

std::wchar_t const& operator[](uint32_t pos) const noexcept;

参数Parameters

pos 从零开始的字符位置或索引。pos A zero-based character position, or index.

返回值Return value

hstring 对象内指定位置的字符的引用。A reference to the character at the specified position within the hstring object.

hstring:: operator = (赋值运算符) hstring::operator= (assignment operator)

hstring 对象赋值。Assigns a value to the hstring object.

语法Syntax

winrt::hstring& operator=(winrt::hstring const& h);
winrt::hstring& operator=(std::wstring_view const& v);

参数Parameters

h要分配给hstring对象的hstring值。h An hstring value to assign to the hstring object.

v要分配给hstring对象的std:: wstring_view值。v A std::wstring_view value to assign to the hstring object.

返回值Return value

hstring 对象的引用。A reference to the hstring object.

hstring:: rbegin 函数hstring::rbegin function

返回一个常量反向迭代器,该迭代器指向超出 hstring 对象) 中最后一个字符 (末尾的一个。Returns a const reverse iterator to one beyond the end of (one beyond the last character in) the hstring object.

语法Syntax

std::reverse_iterator<std::wchar_t const*> rbegin() const noexcept;

返回值Return value

一个常数反向迭代器,到超出 hstring 对象) 中最后一个字符 (末尾之外的一个。A const reverse iterator to one beyond the end of (one beyond the last character in) the hstring object.

hstring:: rend 函数hstring::rend function

返回 hstring 对象中第一个字符的常量反向迭代器。Returns a const reverse iterator to the first character in the hstring object.

语法Syntax

std::reverse_iterator<std::wchar_t const*> rend() const noexcept;

返回值Return value

Hstring对象中的第一个字符的常量反向迭代器。A const reverse iterator to the first character in the hstring object.

hstring:: size 函数hstring::size function

返回 hstring 对象中的字符数。Returns the number of characters in the hstring object.

语法Syntax

uint32_t size() const noexcept;

返回值Return value

包含hstring对象中的字符数的uint32_tA uint32_t containing the number of characters in the hstring object.

attach_abi 函数attach_abi function

hstring 对象附加到 Windows 运行时字符串的句柄。Attaches a hstring object to a handle to a Windows Runtime string.

语法Syntax

void attach_abi(winrt::hstring& object, HSTRING value) noexcept;

参数Parameters

object 要对其执行操作的 hstring 对象。object A hstring object to operate on.

value Windows 运行时字符串的句柄。value A handle to a Windows Runtime string.

copy_from_abi 函数copy_from_abi function

将句柄中的 hstring 对象复制到 Windows 运行时字符串的句柄。Copies to a hstring object from a handle to a Windows Runtime string. 清除 hstring,复制参数,并开始管理句柄。Clears the hstring, copies the parameter, and begins managing the handle.

语法Syntax

void copy_from_abi(winrt::hstring& object, HSTRING value);

参数Parameters

object 要对其执行操作的 hstring 对象。object A hstring object to operate on.

value Windows 运行时字符串的句柄。value A handle to a Windows Runtime string.

copy_to_abi 函数copy_to_abi function

hstring 对象复制到 Windows 运行时字符串的句柄。Copies to a handle to a Windows Runtime string from a hstring object.

语法Syntax

void copy_to_abi(winrt::hstring const& object, HSTRING& value);

参数Parameters

object 要对其执行操作的 hstring 对象。object A hstring object to operate on.

value 一个句柄引用,通过它可以复制 hstring的句柄。value A handle reference, via which to copy the hstring's handle.

detach_abi 函数detach_abi function

hstring 对象的句柄分离,可能会将其返回给调用方。Detaches a hstring object from its handle, perhaps to return it to a caller.

语法Syntax

HSTRING detach_abi(winrt::hstring& object) noexcept;
HSTRING detach_abi(winrt::hstring&& object) noexcept;

参数Parameters

object 要对其执行操作的 hstring 对象。object A hstring object to operate on.

返回值Return value

Windows 运行时字符串的句柄。The handle to the Windows Runtime string.

operator! = (不相等运算符) operator!= (inequality operator)

返回一个值,该值指示两个参数是否不相等。Returns a value indicating whether the two parameters are unequal to one another.

语法Syntax

inline bool operator!=(winrt::hstring const& hLeft, winrt::hstring const& hRight) noexcept;
inline bool operator!=(winrt::hstring const& hLeft, std::wstring const& wRight) noexcept;
inline bool operator!=(winrt::hstring const& hLeft, std::wchar_t const* cRight) noexcept;
inline bool operator!=(std::wstring const& wLeft, winrt::hstring const& hRight) noexcept;
inline bool operator!=(std::wchar_t const* cLeft, winrt::hstring const& hRight) noexcept;

参数Parameters

hLeft``hRight要与另一个参数进行比较的hstring值。hLeft hRight An hstring value to compare with the other parameter.

wLeft``wRight std::wstring 要与其他参数进行比较的值。wLeft wRight A std::wstring value to compare with the other parameter.

cLeft``cRight一个指针,指向要与其他参数进行比较的常量wchar_t数组。cLeft cRight A pointer to an array of constant wchar_t to compare with the other parameter.

返回值Return value

true 如果两个参数不相等,则为; 否则为 falsetrue if the two parameters are unequal to one another, otherwise false.

operator + (串联运算符) operator+ (concatenation operator)

返回一个新的 hstring 对象,这是因为将两个参数连接在一起。Returns a new hstring object resulting from concatenating the two parameters together.

语法Syntax

inline hstring operator+(winrt::hstring const& hLeft, winrt::hstring const& hRight);
inline hstring operator+(winrt::hstring const& hLeft, std::wstring const& wRight);
inline hstring operator+(winrt::hstring const& hLeft, std::wstring_view const& vRight);
inline hstring operator+(winrt::hstring const& hLeft, std::wchar_t const* cRight);
inline hstring operator+(winrt::hstring const& hLeft, std::wchar_t scRight);
inline hstring operator+(std::wstring const& wLeft, winrt::hstring const& hRight);
inline hstring operator+(std::wstring_view const& vLeft, winrt::hstring const& hRight);
inline hstring operator+(std::wchar_t const* cLeft, winrt::hstring const& hRight);
inline hstring operator+(std::wchar_t scLeft, winrt::hstring const& hRight);

参数Parameters

hLeft``hRight要与另一个参数连接的hstring值。hLeft hRight An hstring value to concatenate with the other parameter.

wLeft``wRight std::wstring 要与其他参数连接的值。wLeft wRight A std::wstring value to concatenate with the other parameter.

vLeft``vRight要与另一个参数连接的std:: wstring_view值。vLeft vRight A std::wstring_view value to concatenate with the other parameter.

cLeft``cRight一个指针,指向要与其他参数连接的常量wchar_t数组。cLeft cRight A pointer to an array of constant wchar_t to concatenate with the other parameter.

scLeft``scRight要与另一个参数连接的wchar_tscLeft scRight A wchar_t to concatenate with the other parameter.

返回值Return value

一个新的 hstring 对象,导致将两个参数连接在一起。A new hstring object resulting from concatenating the two parameters together.

运算符< (小于运算符) operator< (less-than operator)

返回一个值,该值指示第一个参数是否小于第二个参数。Returns a value indicating whether the first parameter is less than the second parameter.

语法Syntax

inline bool operator<(winrt::hstring const& hLeft, winrt::hstring const& hRight) noexcept;
inline bool operator<(winrt::hstring const& hLeft, std::wstring const& wRight) noexcept;
inline bool operator<(winrt::hstring const& hLeft, std::wchar_t const* cRight) noexcept;
inline bool operator<(std::wstring const& wLeft, winrt::hstring const& hRight) noexcept;
inline bool operator<(std::wchar_t const* cLeft, winrt::hstring const& hRight) noexcept;

参数Parameters

hLeft``hRight要与另一个参数进行比较的hstring值。hLeft hRight An hstring value to compare with the other parameter.

wLeft``wRight std::wstring 要与其他参数进行比较的值。wLeft wRight A std::wstring value to compare with the other parameter.

cLeft``cRight一个指针,指向要与其他参数进行比较的常量wchar_t数组。cLeft cRight A pointer to an array of constant wchar_t to compare with the other parameter.

返回值Return value

true 如果第一个参数小于第二个参数,则为; 否则为 falsetrue if the first parameter is less than the second parameter, otherwise false.

运算符<= (小于或等于运算符) operator<= (less-than-or-equal-to operator)

返回一个值,该值指示第一个参数是否小于或等于第二个参数。Returns a value indicating whether the first parameter is less than or equal to the second parameter.

语法Syntax

inline bool operator<=(winrt::hstring const& hLeft, winrt::hstring const& hRight) noexcept;
inline bool operator<=(winrt::hstring const& hLeft, std::wstring const& wRight) noexcept;
inline bool operator<=(winrt::hstring const& hLeft, std::wchar_t const* cRight) noexcept;
inline bool operator<=(std::wstring const& wLeft, winrt::hstring const& hRight) noexcept;
inline bool operator<=(std::wchar_t const* cLeft, winrt::hstring const& hRight) noexcept;

参数Parameters

hLeft``hRight要与另一个参数进行比较的hstring值。hLeft hRight An hstring value to compare with the other parameter.

wLeft``wRight std::wstring 要与其他参数进行比较的值。wLeft wRight A std::wstring value to compare with the other parameter.

cLeft``cRight一个指针,指向要与其他参数进行比较的常量wchar_t数组。cLeft cRight A pointer to an array of constant wchar_t to compare with the other parameter.

返回值Return value

true 如果第一个参数小于或等于第二个参数,则为; 否则为 falsetrue if the first parameter is less than or equal to the second parameter, otherwise false.

operator = = (相等运算符) operator== (equality operator)

返回一个值,该值指示两个参数是否相等。Returns a value indicating whether the two parameters are equal to one another.

语法Syntax

inline bool operator==(winrt::hstring const& hLeft, winrt::hstring const& hRight) noexcept;
inline bool operator==(winrt::hstring const& hLeft, std::wstring const& wRight) noexcept;
inline bool operator==(winrt::hstring const& hLeft, std::wchar_t const* cRight) noexcept;
inline bool operator==(std::wstring const& wLeft, winrt::hstring const& hRight) noexcept;
inline bool operator==(std::wchar_t const* cLeft, winrt::hstring const& hRight) noexcept;

参数Parameters

hLeft``hRight要与另一个参数进行比较的hstring值。hLeft hRight An hstring value to compare with the other parameter.

wLeft``wRight std::wstring 要与其他参数进行比较的值。wLeft wRight A std::wstring value to compare with the other parameter.

cLeft``cRight一个指针,指向要与其他参数进行比较的常量wchar_t数组。cLeft cRight A pointer to an array of constant wchar_t to compare with the other parameter.

返回值Return value

true 如果两个参数相等,则为; 否则为 falsetrue if the two parameters are equal to one another, otherwise false.

运算符> (大于运算符) operator> (greater-than operator)

返回一个值,该值指示第一个参数是否大于第二个参数。Returns a value indicating whether the first parameter is greater than the second parameter.

语法Syntax

inline bool operator>(winrt::hstring const& hLeft, winrt::hstring const& hRight) noexcept;
inline bool operator>(winrt::hstring const& hLeft, std::wstring const& wRight) noexcept;
inline bool operator>(winrt::hstring const& hLeft, std::wchar_t const* cRight) noexcept;
inline bool operator>(std::wstring const& wLeft, winrt::hstring const& hRight) noexcept;
inline bool operator>(std::wchar_t const* cLeft, winrt::hstring const& hRight) noexcept;

参数Parameters

hLeft``hRight要与另一个参数进行比较的hstring值。hLeft hRight An hstring value to compare with the other parameter.

wLeft``wRight std::wstring 要与其他参数进行比较的值。wLeft wRight A std::wstring value to compare with the other parameter.

cLeft``cRight一个指针,指向要与其他参数进行比较的常量wchar_t数组。cLeft cRight A pointer to an array of constant wchar_t to compare with the other parameter.

返回值Return value

true 如果第一个参数大于第二个参数,则为; 否则为 falsetrue if the first parameter is greater than the second parameter, otherwise false.

运算符>= (大于或等于运算符) operator>= (greater-than-or-equal-to operator)

返回一个值,该值指示第一个参数是否大于或等于第二个参数。Returns a value indicating whether the first parameter is greater than or equal to the second parameter.

语法Syntax

inline bool operator>=(winrt::hstring const& hLeft, winrt::hstring const& hRight) noexcept;
inline bool operator>=(winrt::hstring const& hLeft, std::wstring const& wRight) noexcept;
inline bool operator>=(winrt::hstring const& hLeft, std::wchar_t const* cRight) noexcept;
inline bool operator>=(std::wstring const& wLeft, winrt::hstring const& hRight) noexcept;
inline bool operator>=(std::wchar_t const* cLeft, winrt::hstring const& hRight) noexcept;

参数Parameters

hLeft``hRight要与另一个参数进行比较的hstring值。hLeft hRight An hstring value to compare with the other parameter.

wLeft``wRight std::wstring 要与其他参数进行比较的值。wLeft wRight A std::wstring value to compare with the other parameter.

cLeft``cRight一个指针,指向要与其他参数进行比较的常量wchar_t数组。cLeft cRight A pointer to an array of constant wchar_t to compare with the other parameter.

返回值Return value

true 如果第一个参数大于或等于第二个参数,则为; 否则为 falsetrue if the first parameter is greater than or equal to the second parameter, otherwise false.

另请参阅See also