Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
steve02081504 committed Sep 12, 2023
1 parent 4cdd5f3 commit 50fc39d
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 9 deletions.
13 changes: 13 additions & 0 deletions parts/header_file/files/elc/_files/base/container/array/defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ namespace array_n{
array_t(U&&a)noexcept(get<T>.as_array.nothrow<U>){
_m=get<T>.as_array(forward<U>(a));
}
/*初始化器进行构建*/
template<class Func> requires(invoke<Func>.with_return_type<T>.able<>)
array_t(note::size_t<size_t>size, Func&&func)noexcept(get<T>.nothrow<Func>){
_m=get<T>[size.value]();
for(auto&i:*this)
i=func();
}
template<class Func> requires(invoke<Func>.with_return_type<T>.able<size_t>)
array_t(note::size_t<size_t>size, Func&&func)noexcept(get<T>.nothrow<Func>){
_m=get<T>[size.value]();
for(size_t i=0;i<size.value;++i)
(*this)[i]=func(i);
}

//复制和移动函数
array_t(const this_t&a)noexcept_as(declvalue(this_t).copy()):array_t(a.copy()){}
Expand Down
51 changes: 43 additions & 8 deletions parts/header_file/files/elc/_files/base_defs/math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,42 @@ namespace math{
template<typename T>
concept is_unsigned_basic_float_type=unsigned_basic_float_type<T>;

/// 大整数类型概念
template<typename T>
concept big_integer_type=integer_type<T> && big_type<T>;
template<typename T>
concept is_big_integer_type=big_integer_type<T>;

/// 大浮点数类型概念
template<typename T>
concept big_float_type=float_type<T> && big_type<T>;
template<typename T>
concept is_big_float_type=big_float_type<T>;

/// 无符号大整数类型概念
template<typename T>
concept unsigned_big_integer_type=big_integer_type<T> && is_unsigned<T>;
template<typename T>
concept is_unsigned_big_integer_type=unsigned_big_integer_type<T>;

/// 有符号大整数类型概念
template<typename T>
concept signed_big_integer_type=big_integer_type<T> && is_signed<T>;
template<typename T>
concept is_signed_big_integer_type=signed_big_integer_type<T>;

/// 无符号大浮点数类型概念
template<typename T>
concept unsigned_big_float_type=big_float_type<T> && is_unsigned<T>;
template<typename T>
concept is_unsigned_big_float_type=unsigned_big_float_type<T>;

/// 有符号大浮点数类型概念
template<typename T>
concept signed_big_float_type=big_float_type<T> && is_signed<T>;
template<typename T>
concept is_signed_big_float_type=signed_big_float_type<T>;

/// 有NaN的类型概念
template<typename T>
concept has_NaN=arithmetic_type_info_prover<remove_cvref<T>>::has_NaN;
Expand Down Expand Up @@ -210,21 +246,20 @@ namespace math{
return false;
}
/*! 符号位设置 */
template<arithmetic_type T>
[[nodiscard]]force_inline constexpr T copy_as_negative(auto x,bool negative=1)noexcept{
template<typename T=void,typename Arg_t=void>
[[nodiscard]]force_inline constexpr auto copy_as_negative(Arg_t x,bool negative=1)noexcept{
if constexpr(is_unsigned<T>)
template_error("copy_as_negative:unsigned type");
if constexpr(is_basic_type<decltype(x)>){
if constexpr(is_float_type<decltype(x)>)
elseif constexpr(type_info<T> == type_info<void>)
return copy_as_negative<to_signed_t<Arg_t>>(x,negative);
elseif constexpr(is_basic_type<Arg_t>) {
if constexpr(is_float_type<Arg_t>)
return(T)::std::copysign(x,negative?-1:1);
else
return(T)negative?T{}-x:x;
}
else
return copy_as_negative<T>((T)x,negative);
}
[[nodiscard]]force_inline constexpr auto copy_as_negative(auto x,bool negative=1)noexcept{
return copy_as_negative<to_signed_t<decltype(x)>>(x,negative);
return(T)negative?T{}-x:x;
}
[[nodiscard]]force_inline constexpr auto copy_as_not_negative(auto x)noexcept{
return copy_as_negative(x,false);
Expand Down
2 changes: 1 addition & 1 deletion parts/header_file/files/elc/_files/random/defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ namespace rand_n{
template<class T>
struct rand_t:base_rand_t{
static constexpr bool common_able=::std::is_trivially_constructible_v<T>;
static constexpr bool range_able=is_arithmetic_type<T> && !(is_float_type<T> && is_big_type<T>);//大浮点数不支持范围(因为其无限精度)
static constexpr bool range_able=is_arithmetic_type<T> && !is_big_float_type<T>;//大浮点数不支持范围(因为其无限精度)
static constexpr bool able=common_able || range_able;
static constexpr bool nothrow=able;
private:
Expand Down

0 comments on commit 50fc39d

Please sign in to comment.