名稱空間
變體
操作

std::experimental::ranges::StrictTotallyOrdered, std::experimental::ranges::StrictTotallyOrderedWith

來自 cppreference.com
< cpp‎ | experimental‎ | ranges
 
 
實驗性
技術規範
檔案系統庫 (檔案系統 TS)
庫基礎 (庫基礎 TS)
庫基礎 2 (庫基礎 TS v2)
庫基礎 3 (庫基礎 TS v3)
並行性擴充套件 (並行性 TS)
並行性擴充套件 2 (並行性 TS v2)
併發性擴充套件 (併發性 TS)
併發擴充套件 2 (併發 TS v2)
概念 (概念 TS)
範圍 (範圍 TS)
反射 (反射 TS)
數學特殊函式 (特殊函式 TR)
實驗性非 TS
模式匹配
線性代數
std::execution
契約
2D 圖形
 
 
概念庫
核心語言概念
                              
物件概念
                              
                              
比較概念
StrictTotallyOrderedStrictTotallyOrderedWith
可呼叫概念
                                        
                              
URNG 概念
 
定義於標頭檔案 <experimental/ranges/concepts>
template< class T >

concept bool StrictTotallyOrdered =
    EqualityComparable<T> &&
    requires(const std::remove_reference_t<T>& a,
             const std::remove_reference_t<T>& b) {
        { a < b }  -> Boolean&&;
        { a > b }  -> Boolean&&;
        { a <= b } -> Boolean&&;
        { a >= b } -> Boolean&&;

    };
(1) (ranges TS)
template< class T, class U >

concept bool StrictTotallyOrderedWith =
    StrictTotallyOrdered<T> &&
    StrictTotallyOrdered<U> &&
    CommonReference<
        const std::remove_reference_t<T>&,
        const std::remove_reference_t<U>&> &&
    StrictTotallyOrdered<
        ranges::common_reference_t<
            const std::remove_reference_t<T>&,
            const std::remove_reference_t<U>&>> &&
    EqualityComparableWith<T, U> &&
    requires(const std::remove_reference_t<T>& t,
             const std::remove_reference_t<U>& u) {
        { t < u }  -> Boolean&&;
        { t > u }  -> Boolean&&;
        { t <= u } -> Boolean&&;
        { t >= u } -> Boolean&&;
        { u < t }  -> Boolean&&;
        { u > t }  -> Boolean&&;
        { u <= t } -> Boolean&&;
        { u >= t } -> Boolean&&;

    };
(2) (ranges TS)
1) 概念 StrictTotallyOrdered<T> 指定了 T 上的比較運算子 ==,!=,<,>,<=,>= 的結果與 T 上的 嚴格全序 一致。

僅當給定型別為 const std::remove_reference_t<T> 的左值 abc 時,StrictTotallyOrdered<T> 才滿足:

  • 以下三者中,有且僅有一個為 truebool(a < b)bool(a > b)bool(a == b)
  • 如果 bool(a < b)bool(b < c) 都為 true,那麼 bool(a < c)true
  • bool(a > b) == bool(b < a)
  • bool(a >= b) == !bool(a < b)
  • bool(a <= b) == !bool(b < a)
2) 概念 StrictTotallyOrderedWith<T, U> 指定了 TU(可能混合)運算元上的比較運算子 ==,!=,<,>,<=,>= 的結果與嚴格全序一致。比較混合運算元的結果等價於比較轉換為它們共同型別的運算元。

形式上,僅當給定型別為 const std::remove_reference_t<T> 的任何左值 t 和型別為 const std::remove_reference_t<U> 的任何左值 u,並且令 Cranges::common_reference_t<const std::remove_reference_t<T>&, const std::remove_reference_t<U>&> 時,StrictTotallyOrderedWith<T, U> 才滿足:

  • bool(t < u) == bool(C(t) < C(u))
  • bool(t > u) == bool(C(t) > C(u))
  • bool(t <= u) == bool(C(t) <= C(u))
  • bool(t >= u) == bool(C(t) >= C(u))
  • bool(u < t) == bool(C(u) < C(t))
  • bool(u > t) == bool(C(u) > C(t))
  • bool(u <= t) == bool(C(u) <= C(t))
  • bool(u >= t) == bool(C(u) >= C(t))

[編輯] 相等性保持

如果一個表示式在給定相等輸入時產生相等輸出,則稱其為保持相等性

  • 表示式的輸入由其運算元組成。
  • 表示式的輸出由其結果以及被表示式修改的所有運算元(如果有的話)組成。

所有要求保持相等性的表示式還必須是穩定的:在沒有顯式介入修改輸入物件的情況下,對具有相同輸入物件的表示式的兩次求值必須產生相等的輸出。

除非另有說明,requires-expression 中使用的每個表示式都必須保持相等且穩定,並且表示式的評估只能修改其非常量運算元。常量運算元不得修改。

[編輯] 隱式表示式變體

如果一個 `requires-expression` 使用了一個對某個 `const` 左值運算元而言非修改的表示式,那麼它也會隱式地要求該表示式的其他變體,這些變體接受非 `const` 左值或(可能 `const`)右值作為給定運算元,除非明確要求具有不同語義的此類表示式變體。這些*隱式表示式變體*必須滿足所宣告表示式的相同語義要求。實現驗證這些變體語法的程度未指定。