ELC in dev
ELC-lang
载入中...
搜索中...
未找到
elc::defs::base::compare_t结构体 参考

Public 类型

template<class T , class U = T>
using type = decltype(base_call((::std::declval< T >()),(::std::declval< U >())))
 

Public 成员函数

template<typename T , typename U >
constexpr auto operator() (T &&a, U &&b) const noexcept(nothrow< T, U >)
 
template<typename T , typename U >
constexpr auto operator() (T *a, U *b, size_t size) const noexcept(nothrow< T, U >)
 
template<typename T , typename U , size_t N1, size_t N2>
constexpr auto operator() (T(&a)[N1], U(&b)[N2]) const noexcept(nothrow< T, U >)
 
template<typename T , typename U >
constexpr auto operator() (T *a, size_t size1, U *b, size_t size2) const noexcept(nothrow< T, U >)
 
template<typename T , typename U >
constexpr auto operator() (T *a, size_t size1, U *b, end_by_zero_t) const noexcept(nothrow< T, U >)
 
template<typename T , typename U >
constexpr auto operator() (T *a, end_by_zero_t, U *b, size_t size2) const noexcept(nothrow< T, U >)
 
template<typename T , typename U >
constexpr auto operator() (T *a, end_by_zero_t, U *b, end_by_zero_t) const noexcept(nothrow< T, U >)
 
template<typename T , typename U >
constexpr auto operator() (T *a, size_t size1, just_an_part_t, U *b, end_by_zero_t) const noexcept(nothrow< T, U >)
 
template<typename T , typename U >
constexpr auto lexicographical (T *a, size_t size1, U *b, size_t size2) const noexcept(nothrow< T, U >)
 
template<typename T , typename U , size_t N1, size_t N2>
constexpr auto lexicographical (T(&a)[N1], U(&b)[N2]) const noexcept(nothrow< T, U >)
 
template<typename T , typename U >
constexpr auto lexicographical (T *a, size_t size1, U *b, end_by_zero_t) const noexcept(nothrow< T, U >)
 
template<typename T , typename U >
constexpr auto lexicographical (T *a, end_by_zero_t, U *b, size_t size2) const noexcept(nothrow< T, U >)
 
template<typename T , typename U >
constexpr auto lexicographical (T *a, end_by_zero_t, U *b, end_by_zero_t) const noexcept(nothrow< T, U >)
 
template<typename T , typename U >
constexpr auto lexicographical (T *a, size_t size1, just_an_part_t, U *b, end_by_zero_t) const noexcept(nothrow< T, U >)
 
constexpr auto reverse (partial_ordering odr) const noexcept
 
constexpr auto reverse (weak_ordering odr) const noexcept
 
constexpr auto reverse (strong_ordering odr) const noexcept
 

静态 Public 属性

template<class T , class U = T>
static constexpr bool able
 
template<class T , class U = T>
static constexpr bool nothrow
 

详细描述

若大小相同则以字典序三路比较任意支持比较的类型或其数组,并在 <=> 不可用时以 < 和 == 为后备. 用法: 判断两者是否可真的进行三路比较。 compare.r_able<类型1,类型2(可选,默认与1相同)> -> bool 判断两者是否可进行compare操作。 compare.able<类型1,类型2(可选,默认与1相同)> -> bool 判断将两者进行三路比较是否会抛出异常。 compare.nothrow<类型1,类型2(可选,默认与1相同)> -> bool

compare(T1,T2) compare(T1[N1],T2[N2]) compare(T1*,size1,T2*,size2) compare(T1*,T2*,size) 返回类型语义上是三路比较的结果类型,具体类型视情况而定.

以字典序进行三路比较。 compare.lexicographical(T1,T2) compare.lexicographical(T1[N1],T2[N2]) compare.lexicographical(T1*,size1,T2*,size2) compare.lexicographical(T1*,T2*,size) 返回类型语义上是三路比较的结果类型,具体类型视情况而定.

翻转三路比较的结果类型。 compare.reverse(order) 返回对应结果类型的反义,与零相等或无法比较时则返回其本身。

在文件 all_defs.cpp1960 行定义.

成员类型定义说明

◆ type

template<class T , class U = T>
using elc::defs::base::compare_t::type = decltype(base_call((::std::declval< T >()),(::std::declval< U >())))

在文件 all_defs.cpp1993 行定义.

成员函数说明

◆ lexicographical() [1/6]

template<typename T , typename U >
constexpr auto elc::defs::base::compare_t::lexicographical ( T *  a,
end_by_zero_t  ,
U b,
end_by_zero_t   
) const
inlineconstexprnoexcept

在文件 all_defs.cpp2114 行定义.

2114 {
2115 floop{
2116 if(*a==T{0})
2117 return *b==U{0}?strong_ordering::equivalent:
2118 strong_ordering::less;
2119 if(auto tmp=base_call(*a,*b); tmp!=0)
2120 return tmp;
2121 a++;
2122 b++;
2123 }
2124 }
#define floop
Definition all_defs.cpp:543
constexpr T down_cast(U a) noexcept
向下转型至

◆ lexicographical() [2/6]

template<typename T , typename U >
constexpr auto elc::defs::base::compare_t::lexicographical ( T *  a,
end_by_zero_t  ,
U b,
size_t  size2 
) const
inlineconstexprnoexcept

在文件 all_defs.cpp2101 行定义.

2101 {
2102 while(size2--){
2103 if(*a==T{0})
2104 return strong_ordering::less;
2105 if(auto tmp=base_call(*a,*b); tmp!=0)
2106 return tmp;
2107 a++;
2108 b++;
2109 }
2110 return *b==U{0}?strong_ordering::equivalent:
2111 strong_ordering::less;
2112 }

◆ lexicographical() [3/6]

template<typename T , typename U >
constexpr auto elc::defs::base::compare_t::lexicographical ( T *  a,
size_t  size1,
just_an_part_t  ,
U b,
end_by_zero_t   
) const
inlineconstexprnoexcept

在文件 all_defs.cpp2126 行定义.

2126 {
2127 while(size1--){
2128 if(*b==U{0})
2129 return strong_ordering::greater;
2130 if(auto tmp=base_call(*a,*b); tmp!=0)
2131 return tmp;
2132 a++;
2133 b++;
2134 }
2135 return strong_ordering::equivalent;
2136 }

◆ lexicographical() [4/6]

template<typename T , typename U >
constexpr auto elc::defs::base::compare_t::lexicographical ( T *  a,
size_t  size1,
U b,
end_by_zero_t   
) const
inlineconstexprnoexcept

在文件 all_defs.cpp2088 行定义.

2088 {
2089 while(size1--){
2090 if(*b==U{0})
2091 return strong_ordering::greater;
2092 if(auto tmp=base_call(*a,*b); tmp!=0)
2093 return tmp;
2094 a++;
2095 b++;
2096 }
2097 return *b==U{0}?strong_ordering::equivalent:
2098 strong_ordering::less;
2099 }

◆ lexicographical() [5/6]

template<typename T , typename U >
constexpr auto elc::defs::base::compare_t::lexicographical ( T *  a,
size_t  size1,
U b,
size_t  size2 
) const
inlineconstexprnoexcept

在文件 all_defs.cpp2076 行定义.

2076 {
2077 using ::std::min;//elc的min依赖compare,而compare还没有定义完全,所以这里用std的
2078 if(auto tmp=operator()(a,b,min(size1,size2)); tmp!=0)
2079 return tmp;
2080 else
2081 return size1<=>size2;
2082 }
constexpr struct elc::defs::base::min_t min

◆ lexicographical() [6/6]

template<typename T , typename U , size_t N1, size_t N2>
constexpr auto elc::defs::base::compare_t::lexicographical ( T(&)  a[N1],
U(&)  b[N2] 
) const
inlineconstexprnoexcept

在文件 all_defs.cpp2084 行定义.

2084 {
2085 return lexicographical(a,N1,b,N2);
2086 }
constexpr auto lexicographical(T *a, size_t size1, U *b, size_t size2) const noexcept(nothrow< T, U >)

◆ operator()() [1/8]

template<typename T , typename U >
constexpr auto elc::defs::base::compare_t::operator() ( T &&  a,
U &&  b 
) const
inlineconstexprnoexcept

在文件 all_defs.cpp1996 行定义.

1996 {
1997 return base_call(a,b);
1998 }

◆ operator()() [2/8]

template<typename T , typename U >
constexpr auto elc::defs::base::compare_t::operator() ( T *  a,
end_by_zero_t  ,
U b,
end_by_zero_t   
) const
inlineconstexprnoexcept

在文件 all_defs.cpp2051 行定义.

2051 {
2052 type<T,U> tmp=strong_ordering::equivalent;
2053 floop{
2054 if(*a==T{0})
2055 return *b==U{0}?tmp:strong_ordering::less;
2056 if(tmp==0)
2057 tmp=base_call(*a,*b);
2058 a++;
2059 b++;
2060 }
2061 }

◆ operator()() [3/8]

template<typename T , typename U >
constexpr auto elc::defs::base::compare_t::operator() ( T *  a,
end_by_zero_t  ,
U b,
size_t  size2 
) const
inlineconstexprnoexcept

在文件 all_defs.cpp2038 行定义.

2038 {
2039 type<T,U> tmp=strong_ordering::equivalent;
2040 while(size2--){
2041 if(*a==T{0})
2042 return strong_ordering::less;
2043 if(tmp==0)
2044 tmp=base_call(*a,*b);
2045 a++;
2046 b++;
2047 }
2048 return *b==U{0}?tmp:strong_ordering::less;
2049 }

◆ operator()() [4/8]

template<typename T , typename U >
constexpr auto elc::defs::base::compare_t::operator() ( T *  a,
size_t  size1,
just_an_part_t  ,
U b,
end_by_zero_t   
) const
inlineconstexprnoexcept

在文件 all_defs.cpp2063 行定义.

2063 {
2064 type<T,U> tmp=strong_ordering::equivalent;
2065 while(size1--){
2066 if(*b==U{0})
2067 return strong_ordering::greater;
2068 if(tmp==0)
2069 tmp=base_call(*a,*b);
2070 a++;
2071 b++;
2072 }
2073 return tmp;
2074 }

◆ operator()() [5/8]

template<typename T , typename U >
constexpr auto elc::defs::base::compare_t::operator() ( T *  a,
size_t  size1,
U b,
end_by_zero_t   
) const
inlineconstexprnoexcept

在文件 all_defs.cpp2025 行定义.

2025 {
2026 type<T,U> tmp=strong_ordering::equivalent;
2027 while(size1--){
2028 if(*b==U{0})
2029 return strong_ordering::greater;
2030 if(tmp==0)
2031 tmp=base_call(*a,*b);
2032 a++;
2033 b++;
2034 }
2035 return *b==U{0}?tmp:strong_ordering::less;
2036 }

◆ operator()() [6/8]

template<typename T , typename U >
constexpr auto elc::defs::base::compare_t::operator() ( T *  a,
size_t  size1,
U b,
size_t  size2 
) const
inlineconstexprnoexcept

在文件 all_defs.cpp2017 行定义.

2017 {
2019 if(tmp!=0)
2020 return tmp;
2021 else
2022 return operator()(a,b,size1);
2023 }
constexpr auto operator()(T &&a, U &&b) const noexcept(nothrow< T, U >)

◆ operator()() [7/8]

template<typename T , typename U >
constexpr auto elc::defs::base::compare_t::operator() ( T *  a,
U b,
size_t  size 
) const
inlineconstexprnoexcept

在文件 all_defs.cpp2000 行定义.

2000 {
2001 while(size--){
2002 if(auto tmp=base_call(*(a++),*(b++)); tmp!=0)
2003 return tmp;
2004 }
2005 return strong_ordering::equivalent;
2006 }

◆ operator()() [8/8]

template<typename T , typename U , size_t N1, size_t N2>
constexpr auto elc::defs::base::compare_t::operator() ( T(&)  a[N1],
U(&)  b[N2] 
) const
inlineconstexprnoexcept

在文件 all_defs.cpp2008 行定义.

2008 {
2009 if constexpr(N1==N2)
2010 return operator()(a,b,N1);
2011 else{
2012 template_warning("N1!=N2");
2013 return N1<=>N2;
2014 }
2015 }
#define template_warning(reason)
Definition all_defs.cpp:563

◆ reverse() [1/3]

constexpr auto elc::defs::base::compare_t::reverse ( partial_ordering  odr) const
inlineconstexprnoexcept

在文件 all_defs.cpp2138 行定义.

2138 {
2139 if(odr==partial_ordering::greater)
2140 return partial_ordering::less;
2141 elseif(odr==partial_ordering::less)
2142 return partial_ordering::greater;
2143 else
2144 return odr;
2145 }
#define elseif
Definition all_defs.cpp:650
这是这个函数的调用关系图:

◆ reverse() [2/3]

constexpr auto elc::defs::base::compare_t::reverse ( strong_ordering  odr) const
inlineconstexprnoexcept

在文件 all_defs.cpp2154 行定义.

2154 {
2155 if(odr==strong_ordering::greater)
2156 return strong_ordering::less;
2157 elseif(odr==strong_ordering::less)
2158 return strong_ordering::greater;
2159 else
2160 return odr;
2161 }

◆ reverse() [3/3]

constexpr auto elc::defs::base::compare_t::reverse ( weak_ordering  odr) const
inlineconstexprnoexcept

在文件 all_defs.cpp2146 行定义.

2146 {
2147 if(odr==weak_ordering::greater)
2148 return weak_ordering::less;
2149 elseif(odr==weak_ordering::less)
2150 return weak_ordering::greater;
2151 else
2152 return odr;
2153 }

类成员变量说明

◆ able

template<class T , class U = T>
constexpr bool elc::defs::base::compare_t::able
staticconstexpr
初始值:
(bool(requires{ (::std::declval< T >())==(::std::declval< U >()), (::std::declval< T >())<(::std::declval< U >()), (::std::declval< U >())<(::std::declval< T >()) ;}))

在文件 all_defs.cpp1966 行定义.

◆ nothrow

template<class T , class U = T>
constexpr bool elc::defs::base::compare_t::nothrow
staticconstexpr
初始值:
= (bool(requires{ (::std::declval< T >())<=>(::std::declval< U >()) ;{ (::std::declval< T >())<=>(::std::declval< U >()) }noexcept;})) ||
(bool(requires{ (::std::declval< T >())==(::std::declval< U >()), (::std::declval< T >())<(::std::declval< U >()), (::std::declval< U >())<(::std::declval< T >()) ;{ (::std::declval< T >())==(::std::declval< U >()), (::std::declval< T >())<(::std::declval< U >()), (::std::declval< U >())<(::std::declval< T >()) }noexcept;}))

在文件 all_defs.cpp1973 行定义.


该结构体的文档由以下文件生成: