Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
steve02081504 committed Oct 24, 2023
1 parent f4701c6 commit f8c8d91
Show file tree
Hide file tree
Showing 23 changed files with 222 additions and 212 deletions.
42 changes: 21 additions & 21 deletions parts/_share/_defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,33 +212,33 @@ class name{}\
#define was_not_an_ill_form_and_noexcept(...) (bool(requires{__VA_ARGS__;{__VA_ARGS__}noexcept;}))
#define was_not_an_ill_form_with_parameter(...) (bool(requires __VA_ARGS__ ))

/*! 让lambda递归更加美观 */
#define recursive_lambda(...) lambda(auto&&lambda_RLSRRS,__VA_ARGS__)
/*! 让lambda递归更加美观 */
#define get_recursive_lambda_caller(name,...) \
exlambda(auto&&...Args)__VA_ARGS__ lambda_force_inline{\
/*! 让λ递归更加美观 */
#define recursive_λ(...) λ(auto&&λ_RLSRRS,__VA_ARGS__)
/*! 让λ递归更加美观 */
#define get_recursive_λ_caller(name,...) \
exλ(auto&&...Args)__VA_ARGS__ λ_force_inline{\
return name(name,Args...);\
}
/*! 让lambda定义更加美观 */
#define lambda []
/*! 让lambda定义更加美观 */
#define exlambda [&]
/*! 让lambda定义更加美观 */
#define lambda_with_catch(...) [__VA_ARGS__]
/*! 让lambda定义更加美观 */
#define self_recursion(...) lambda_RLSRRS(lambda_RLSRRS,__VA_ARGS__)
//recursive_lambda_self_referential_reserved_symbolname
#define lambda_RLSRRS _my_jb_super_sb_name_
/*! 让λ定义更加美观 */
#define λ []
/*! 让λ定义更加美观 */
#define exλ [&]
/*! 让λ定义更加美观 */
#define λ_with_catch(...) [__VA_ARGS__]
/*! 让λ定义更加美观 */
#define self_recursion(...) λ_RLSRRS(λ_RLSRRS,__VA_ARGS__)
//recursive_λ_self_referential_reserved_symbolname
#define λ_RLSRRS _my_jb_super_sb_name_

#if defined(_MSC_VER) && !defined(__clang__)
#define lambda_inline [[msvc::forceinline]]
#define lambda_force_inline [[msvc::forceinline]]
#define λ_inline [[msvc::forceinline]]
#define λ_force_inline [[msvc::forceinline]]
#elif
#define lambda_inline [[gnu::always_inline]]
#define lambda_force_inline [[gnu::always_inline]]
#define λ_inline [[gnu::always_inline]]
#define λ_force_inline [[gnu::always_inline]]
#else
#define lambda_inline
#define lambda_force_inline
#define λ_inline
#define λ_force_inline
#endif

#define MAGIC//ahh,ko no tenno da!
Expand Down
16 changes: 8 additions & 8 deletions parts/_share/_undefs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@
#undef was_not_an_ill_form_and_noexcept
#undef was_not_an_ill_form_with_parameter

#undef recursive_lambda
#undef get_recursive_lambda_caller
#undef lambda
#undef exlambda
#undef lambda_with_catch
#undef recursive_λ
#undef get_recursive_λ_caller
#undef λ
#undef exλ
#undef λ_with_catch
#undef self_recursion
#undef lambda_RLSRRS
#undef lambda_inline
#undef lambda_force_inline
#undef λ_RLSRRS
#undef λ_inline
#undef λ_force_inline

#undef MAGIC

Expand Down
8 changes: 4 additions & 4 deletions parts/_share/basic_environment/after_math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,31 @@ namespace elc::defs{

/*! 给定大小的无符号整数类型 */
template<size_t size>
using unsigned_specific_size_t=decltype(lambda{
using unsigned_specific_size_t=decltype(λ{
#define TYPE_MAPPER(type) if constexpr(size == sizeof(type))return (type)0;else
#include "./arithmetic_mapper/unsigned_mapper.hpp"
#undef TYPE_MAPPER
{}
}());
/*! 至少有给定大小的快速无符号整数类型 */
template<size_t size>
using unsigned_specific_size_fast_t=decltype(lambda{
using unsigned_specific_size_fast_t=decltype(λ{
#define TYPE_MAPPER(type) if constexpr(size <= sizeof(type))return (type)0;else
#include "./arithmetic_mapper/unsigned_fast_mapper.hpp"
#undef TYPE_MAPPER
{}
}());
/*! 给定大小的有符号整数类型 */
template<size_t size>
using signed_specific_size_t=decltype(lambda{
using signed_specific_size_t=decltype(λ{
#define TYPE_MAPPER(type) if constexpr(size == sizeof(type))return (type)0;else
#include "./arithmetic_mapper/signed_mapper.hpp"
#undef TYPE_MAPPER
{}
}());
/*! 至少有给定大小的快速有符号整数类型 */
template<size_t size>
using signed_specific_size_fast_t=decltype(lambda{
using signed_specific_size_fast_t=decltype(λ{
#define TYPE_MAPPER(type) if constexpr(size <= sizeof(type))return (type)0;else
#include "./arithmetic_mapper/signed_fast_mapper.hpp"
#undef TYPE_MAPPER
Expand Down
4 changes: 2 additions & 2 deletions parts/_share/basic_environment/pre_math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ namespace elc::defs{
typedef ::std::uintmax_t basic_uintmax_t;
typedef ::std::intmax_t basic_intmax_t;
//更新uintmax_t和intmax_t的代指
typedef decltype(lambda{
typedef decltype(λ{
#if defined(ELC_BASE_ENV_HAS_INT128)
if constexpr(sizeof(basic_uintmax_t) < sizeof(uint128_t))
return uint128_t{};
else
#endif
return basic_uintmax_t{};
}()) uintmax_t;
typedef decltype(lambda{
typedef decltype(λ{
#if defined(ELC_BASE_ENV_HAS_INT128)
if constexpr(sizeof(basic_intmax_t) < sizeof(int128_t))
return int128_t{};
Expand Down
14 changes: 7 additions & 7 deletions parts/_share/char_set/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ inline constexpr auto utf8_to_utf16(char16_t *out, const char8_t *in, size_t len
//for return
const auto out_start = out;
const auto in_start = in;
auto result_builder = exlambda(bool success)noexcept{
auto result_builder = exλ(bool success)noexcept{
return code_convert_result<char8_t, char16_t>(success, string_view_t<char8_t>(in_start, in - in_start), string_view_t<char16_t>(out_start, out - out_start));
};
while(in < end){
Expand Down Expand Up @@ -267,7 +267,7 @@ inline constexpr auto utf8_to_utf32(char32_t *out, const char8_t *in, size_t len
//for return
const auto out_start = out;
const auto in_start = in;
auto result_builder = exlambda(bool success)noexcept{
auto result_builder = exλ(bool success)noexcept{
return code_convert_result<char8_t, char32_t>(success, string_view_t<char8_t>(in_start, in - in_start), string_view_t<char32_t>(out_start, out - out_start));
};
while(in < end){
Expand Down Expand Up @@ -309,7 +309,7 @@ inline constexpr auto utf16_to_utf8(char8_t *out, const char16_t *in, size_t len
//for return
const auto out_start = out;
const auto in_start = in;
auto result_builder = exlambda(bool success)noexcept{
auto result_builder = exλ(bool success)noexcept{
return code_convert_result<char16_t, char8_t>(success, string_view_t<char16_t>(in_start, in - in_start), string_view_t<char8_t>(out_start, out - out_start));
};
while(in < end){
Expand Down Expand Up @@ -348,7 +348,7 @@ inline constexpr auto utf16_to_utf32(char32_t *out, const char16_t *in, size_t l
//for return
const auto out_start = out;
const auto in_start = in;
auto result_builder = exlambda(bool success)noexcept{
auto result_builder = exλ(bool success)noexcept{
return code_convert_result<char16_t, char32_t>(success, string_view_t<char16_t>(in_start, in - in_start), string_view_t<char32_t>(out_start, out - out_start));
};
while(in < end){
Expand Down Expand Up @@ -384,7 +384,7 @@ inline constexpr auto utf32_to_utf8(char8_t *out, const char32_t *in, size_t len
//for return
const auto out_start = out;
const auto in_start = in;
auto result_builder = exlambda(bool success)noexcept{
auto result_builder = exλ(bool success)noexcept{
return code_convert_result<char32_t, char8_t>(success, string_view_t<char32_t>(in_start, in - in_start), string_view_t<char8_t>(out_start, out - out_start));
};
while(in < end){
Expand Down Expand Up @@ -419,7 +419,7 @@ inline constexpr auto utf32_to_utf16(char16_t *out, const char32_t *in, size_t l
//for return
const auto out_start = out;
const auto in_start = in;
auto result_builder = exlambda(bool success)noexcept{
auto result_builder = exλ(bool success)noexcept{
return code_convert_result<char32_t, char16_t>(success, string_view_t<char32_t>(in_start, in - in_start), string_view_t<char16_t>(out_start, out - out_start));
};
while(in < end){
Expand Down Expand Up @@ -454,7 +454,7 @@ inline constexpr auto utf32_to_utf32(char32_t *out, const char32_t *in, size_t l
//for return
const auto out_start = out;
const auto in_start = in;
auto result_builder = exlambda(bool success)noexcept{
auto result_builder = exλ(bool success)noexcept{
return code_convert_result<char32_t, char32_t>(success, string_view_t<char32_t>(in_start, in - in_start), string_view_t<char32_t>(out_start, out - out_start));
};
while(in < end){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace function_n{
#else
function_t<void()noexcept>
#endif
a(lambda_with_catch (&tester)()noexcept{ tester=1; });
a(λ_with_catch (&tester)()noexcept{ tester=1; });
static_assert(type_info<decltype(a)> == type_info<function_t<void()noexcept>>);
stest_accert(tester==0);
a();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace map_n{
#define expr declvalue(func_t)(declvalue(T&))
template<typename func_t> requires was_not_an_ill_form(expr)
void for_each(func_t&&func)noexcept_as(expr){
_m.for_each(lambda(data_t&a)noexcept_as(expr){
_m.for_each(λ(data_t&a)noexcept_as(expr){
func(a._value);
});
}
Expand All @@ -114,15 +114,15 @@ namespace map_n{
#define expr declvalue(func_t)(declvalue(const T&))
template<typename func_t> requires was_not_an_ill_form(expr)
void for_each(func_t&&func)const noexcept_as(expr){
_m.for_each(lambda(data_t&a)noexcept_as(expr){
_m.for_each(λ(data_t&a)noexcept_as(expr){
func(add_const<T&>(a._value));
});
}
#undef expr

static constexpr bool shrink_nothow=stack_t<data_t>::remove_nothrow;
void shrink()const noexcept(shrink_nothow){
_m.for_each_bucket(lambda(stack_t<data_t>&a)noexcept(shrink_nothow && equal.nothrow<T>){
_m.for_each_bucket(λ(stack_t<data_t>&a)noexcept(shrink_nothow && equal.nothrow<T>){
while(a.remove(data_t::seek_value_t(const_default_value_of<T>)));
});
}
Expand All @@ -135,7 +135,7 @@ namespace map_n{
if(size()!=a.size())
return 0;
try{
_m.for_each(lambda_with_catch(&a)(data_t&b){
_m.for_each(λ_with_catch(&a)(data_t&b){
if(a[b._key]!=b._value)
throw (this_t*)(nullptr);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ inline void test(){
a.remove(2);
stest_accert(a.size()==2);
int add_num=0;
a.for_each(lambda_with_catch(&add_num)(int a){add_num+=a;});
a.for_each(λ_with_catch(&add_num)(int a){add_num+=a;});
stest_accert(add_num==4);
auto_stack_t<int>b=a;
stest_accert(b.not_in_stack(2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
Checks for memory leaks.
*/
inline void check_memory_lack()noexcept{
stest_mapeventlogwith(lambda(const void*p,steventlist*a)noexcept{
stest_mapeventlogwith(λ(const void*p,steventlist*a)noexcept{
stest_putsf(L"内存泄露于%p,分配自:",p);
stest_printeventlist(stdout,stest_copyeventlist(a));
//alloc_n::base_free(remove_const(p));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class roots_t{

void map_and_mark()noexcept_as(declvalue(value_t)->map_and_mark()){
_roots.for_each(
lambda(value_t&a)noexcept_as(a->map_and_mark())
λ(value_t&a)noexcept_as(a->map_and_mark())
{
a->map_and_mark();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace default_gc_for_type{
roots_of<T>.map_and_mark();
if constexpr(info.has_attribute(can_shrink) || (info.has_attribute(mark_able_for_gc)&&info.has_attribute(have_root)))
map_all<T>(
lambda(T*a)noexcept{
λ(T*a)noexcept{
if constexpr(info.has_attribute(can_shrink))
a->shrink();
if constexpr(info.has_attribute(mark_able_for_gc)&&info.has_attribute(have_root)){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class gc_t{
[[nodiscard]]inline bool success()const noexcept{
bool success=_gc_success_identifiers.empty();
_gc_success_identifiers.for_each(
lambda_with_catch(&success)(const success_identifier_t&a)noexcept{
λ_with_catch(&success)(const success_identifier_t&a)noexcept{
if(not success)
success=a();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,22 @@ namespace math{
}
public:
//bool:是否有默认极限值
static constexpr bool has_epsilon=is_arithmetic_type;
static constexpr bool has_ε=is_arithmetic_type;
public:
static constexpr auto epsilon()noexcept requires(has_epsilon){
static constexpr auto ε()noexcept requires(has_ε){
return ::std::numeric_limits<T>::epsilon();
}
public:
//对应的无符号和有符号类型
using unsigned_type=decltype(lambda{
using unsigned_type=decltype(λ{
if constexpr(type_info<T> == type_info<bool>)
return T();
elseif constexpr(is_float_type)//基础浮点类型没有对应的无符号
return T();
elseif constexpr(is_integer_type)//考虑到charX_t,所有整数类型都应该过一遍make_unsigned_t
return::std::make_unsigned_t<T>();
}());
using signed_type=decltype(lambda{
using signed_type=decltype(λ{
if constexpr(type_info<T> == type_info<bool>)
return T();
elseif constexpr(is_float_type)
Expand All @@ -134,14 +134,14 @@ namespace math{
return::std::make_signed_t<T>();
}());
//对应的浮点数类型
using float_type=decltype(lambda{
using float_type=decltype(λ{
if constexpr(is_float_type)
return T();
elseif constexpr(is_integer_type)
return .0;
}());
//对应的整数类型
using integer_type=decltype(lambda{
using integer_type=decltype(λ{
if constexpr(is_integer_type)
return T();
elseif constexpr(is_float_type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ namespace math{
template<typename T>
concept has_min_max=has_min<T> && has_max<T>;

/// 有epsilon的类型概念
/// 有ε的类型概念
template<typename T>
concept has_epsilon=arithmetic_type_info_prover<remove_cvref<T>>::has_epsilon;
concept has_ε=arithmetic_type_info_prover<remove_cvref<T>>::has_ε;
}
}
using math::to_unsigned_t;
Expand Down
12 changes: 6 additions & 6 deletions parts/header_file/files/elc/_files/base_defs/invoke.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,30 @@ struct invoke_t{
static constexpr bool nothrow= ::std::is_nothrow_invocable_r_v<Ret_t,T,Args...>;

/*!
A function that returns a lambda that applies a function to a value.
A function that returns a λ that applies a function to a value.
@param rest The arguments to the function.
@returns A lambda that applies the function to a value.
@returns A λ that applies the function to a value.
*/
template<class...Args> requires able<Args...>
decltype(auto)_as(Args&&...rest)const noexcept(nothrow<Args...>){//invoke<T>.with_return_type<Ret_t>._as(...)
return lambda_with_catch(rest...)(const T&a)noexcept(nothrow<Args...>){return a(forward<Args>(rest)...);};
return λ_with_catch(rest...)(const T&a)noexcept(nothrow<Args...>){return a(forward<Args>(rest)...);};
}
};
template<class Ret_t>
static constexpr with_return_type_t<Ret_t>with_return_type{};

/*!
A function that returns a lambda that applies a function to a value.
A function that returns a λ that applies a function to a value.
@param rest The arguments to the function.
@returns A lambda that applies the function to a value.
@returns A λ that applies the function to a value.
*/
template<class...Args> requires able<Args...>
decltype(auto)_as(Args&&...rest)const noexcept(nothrow<Args...>){//invoke<T>._as(...)
return lambda_with_catch(rest...)(const T&a)noexcept(nothrow<Args...>){return a(forward<Args>(rest)...);};
return λ_with_catch(rest...)(const T&a)noexcept(nothrow<Args...>){return a(forward<Args>(rest)...);};
}
};
template<typename T>
Expand Down
Loading

0 comments on commit f8c8d91

Please sign in to comment.