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.

SyntaxSyntax

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 物件中第一個字元的 const 反覆運算器。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 物件中第一個字元的 const 反覆運算器。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 從 Windows 執行階段字串的控制碼複製到 hstring 物件。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+ (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<= (小於或等於運算子) 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>= (大於或等於運算子) 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成員函式所定義,其中每個函數都會傳回 const 反覆運算器, (as do 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). 基於這個原因,您可以使用以範圍為基礎hstringfor 語句或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 常數 wchar_t 陣列的指標,此陣列會初始化 hstring 物件。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 物件中第一個字元的 const 反覆運算器。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物件中第一個字元的 const 反覆運算器。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 物件中第一個字元的 const 反覆運算器。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物件中第一個字元的 const 反覆運算器。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

一個 const 反覆運算器,除了 () 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.

SyntaxSyntax

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

一個 const 反覆運算器,除了 () 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

Uint32_t ,其中包含hstring物件中的字元數。A 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

從 Windows 執行階段字串的控制碼複製到 hstring 物件。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+ (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<= (小於或等於運算子) 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>= (大於或等於運算子) 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