命名空间
变体
操作

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

来自 cppreference.cn
< cpp‎ | experimental‎ | ranges
 
 
实验性
技术规范
文件系统库 (filesystem TS)
库基础 (library fundamentals TS)
库基础 2 (library fundamentals TS v2)
库基础 3 (library fundamentals TS v3)
并行性扩展 (parallelism TS)
并行性扩展 2 (parallelism TS v2)
并发性扩展 (concurrency TS)
并发性扩展 2 (concurrency TS v2)
概念 (concepts TS)
范围 (ranges TS)
反射 (reflection TS)
数学特殊函数 (special functions TR)
实验性非 TS
模式匹配
线性代数
std::execution
契约
2D 图形
 
 
概念库
核心语言概念
                              
对象概念
                              
                              
比较概念
StrictTotallyOrderedStrictTotallyOrderedWith
可调用概念
                                        
                              
URNG concept
 
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) (范围 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) (范围 TS)
1) 概念 StrictTotallyOrdered<T> 规定了 T 上的比较运算符 ==,!=,<,>,<=,>= 产生的结果与 T 上的严格全序一致。

仅当给定 const std::remove_reference_t<T> 类型的左值 abc 时,StrictTotallyOrdered<T> 才得到满足

  • 正好 bool(a < b)bool(a > b)bool(a == b) 其中之一为 true
  • 如果 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,也隐式地要求该表达式的额外变体,这些变体接受给定操作数的非常量左值或(可能常量)右值,除非使用不同的语义显式地要求这种表达式变体。这些隐式表达式变体必须满足声明的表达式的相同语义要求。实现验证变体的语法的程度是未指定的。