ELC in dev
ELC-lang
载入中...
搜索中...
未找到
elc::defs::memory::get_n 命名空间参考

struct  base_get_t
 
struct  copy_get_t
 
struct  get_forward_resize_t
 
struct  get_resize_t
 
struct  get_size_of_get_t
 
struct  get_t
 
struct  unget_t
 

函数

template<typename T >
void alloc_size_cut (T *&arg, size_t to_size) noexcept
 
template<typename T >
void alloc_size_grow (T *&arg, size_t to_size) noexcept(move.trivial< T > or move.nothrow< T >)
 
template<typename T >
void alloc_size_grow_with_insert_uninitialized_data (T *&arg, size_t insert_pos, size_t insert_size) noexcept(move.trivial< T > or move.nothrow< T >)
 
template<typename T >
auto alloc_size_grow_with_insert_uninitialized_data (T *&arg, size_t to_size, size_t insert_pos, size_t insert_size) noexcept(move.trivial< T > or move.nothrow< T >)
 
template<typename T >
auto part_used_block_alloc_size_grow_with_insert_uninitialized_data (T *&arg, size_t to_size, size_t insert_pos, size_t insert_size, size_t used_size) noexcept(move.trivial< T > or move.nothrow< T >)
 
template<typename T >
void forward_alloc_size_cut (T *&arg, size_t to_size) noexcept(move.trivial< T > or move.nothrow< T >)
 
template<typename T >
void forward_alloc_size_grow (T *&arg, size_t to_size) noexcept(move.trivial< T > or move.nothrow< T >)
 
template<typename T >
auto forward_alloc_size_grow_with_insert_uninitialized_data (T *&arg, size_t to_size, size_t insert_pos, size_t insert_size) noexcept(move.trivial< T > or move.nothrow< T >)
 
template<typename T >
auto part_used_block_forward_alloc_size_grow_with_insert_uninitialized_data (T *&arg, size_t to_size, size_t insert_pos, size_t insert_size, size_t used_size) noexcept(move.trivial< T > or move.nothrow< T >)
 

变量

template<typename T >
constexpr get_t< T > get {}
 
constexpr struct elc::defs::memory::get_n::unget_t unget
 
constexpr struct elc::defs::memory::get_n::get_resize_t get_resize
 
constexpr struct elc::defs::memory::get_n::get_forward_resize_t get_forward_resize
 
constexpr struct elc::defs::memory::get_n::get_size_of_get_t get_size_of_get
 
constexpr struct elc::defs::memory::get_n::copy_get_t copy_get
 

函数说明

◆ alloc_size_cut()

template<typename T >
void elc::defs::memory::get_n::alloc_size_cut ( T *&  arg,
size_t  to_size 
)
noexcept

向后减小数据块大小并转移原有实例的生命周期,但并不析构旧的实例

参数
arg原有数据块
to_size新的数据块大小

在文件 all_defs.cpp21217 行定义.

21217 {
21218 realloc(arg,to_size);
21219 }
函数调用图:
这是这个函数的调用关系图:

◆ alloc_size_grow()

template<typename T >
void elc::defs::memory::get_n::alloc_size_grow ( T *&  arg,
size_t  to_size 
)
noexcept

向后扩大数据块大小并转移原有实例的生命周期,但并不构造新的实例

参数
arg原有数据块
to_size新的数据块大小

在文件 all_defs.cpp21227 行定义.

21227 {
21228 if constexpr(move.trivial<T>)
21229 realloc(arg,to_size);
21230 else{
21231 T*tmp=alloc<T>(to_size);
21232 const auto from_size=get_size_of_alloc(arg);
21233 if constexpr(!move.nothrow<T>){
21234 template_warning("the move of T was not noexcept,this may cause memory lack.");
21235 try{
21236 move[from_size](note::from(arg),note::to(tmp));
21237 }catch(...){
21238 free(tmp);
21239 throw;
21240 }
21241 }else{
21242 move[from_size](note::from(arg),note::to(tmp));
21243 }
21244 free(arg);
21245 arg=tmp;
21246 }
21247 }
#define template_warning(reason)
Definition all_defs.cpp:563
函数调用图:
这是这个函数的调用关系图:

◆ alloc_size_grow_with_insert_uninitialized_data() [1/2]

template<typename T >
void elc::defs::memory::get_n::alloc_size_grow_with_insert_uninitialized_data ( T *&  arg,
size_t  insert_pos,
size_t  insert_size 
)
noexcept

在指定位置插入未初始化数据块并转移原有实例的生命周期,但并不构造新的实例

参数
arg原有数据块
insert_pos插入位置
insert_size插入大小

在文件 all_defs.cpp21256 行定义.

21256 {
21257 const auto from_size=get_size_of_alloc(arg);
21258 const auto to_size=from_size+insert_size;
21259 const auto size_before_insert=insert_pos;
21260 #if in_debug || defined(ELC_CHECK_MEMORYS_ERROR)
21261 if(from_size<insert_pos)
21262 __debugbreak();//?
21263 #endif
21264 const auto size_after_insert=from_size-insert_pos;
21265 if constexpr(move.trivial<T>){
21266 realloc(arg,to_size);
21267 memmove(arg+size_before_insert+insert_size,arg+size_before_insert,size_after_insert*sizeof(T));
21268 }
21269 else{
21270 T*tmp=alloc<T>(to_size);
21271 if constexpr(!move.nothrow<T>){
21272 template_warning("the move of T was not noexcept,this may cause memory lack.");
21273 try{
21274 move[size_before_insert](note::from(arg),note::to(tmp));
21275 move[size_after_insert](note::from(arg+insert_pos),note::to(tmp+insert_pos+insert_size));
21276 }catch(...){
21277 free(tmp);
21278 throw;
21279 }
21280 }else{
21281 move[size_before_insert](note::from(arg),note::to(tmp));
21282 move[size_after_insert](note::from(arg+insert_pos),note::to(tmp+insert_pos+insert_size));
21283 }
21284 free(arg);
21285 arg=tmp;
21286 }
21287 }
constexpr struct elc::defs::memory::alloc_n::free_t free
函数调用图:
这是这个函数的调用关系图:

◆ alloc_size_grow_with_insert_uninitialized_data() [2/2]

template<typename T >
auto elc::defs::memory::get_n::alloc_size_grow_with_insert_uninitialized_data ( T *&  arg,
size_t  to_size,
size_t  insert_pos,
size_t  insert_size 
)
inlinenoexcept

在指定位置插入未初始化数据块并转移原有实例的生命周期,但并不构造新的实例 若有多余的大小,追加到末尾

参数
arg原有数据块
to_size新的数据块大小
insert_pos插入位置
insert_size插入大小
返回
详细的操作信息

在文件 all_defs.cpp21300 行定义.

21300 {
21301 const auto from_size=get_size_of_alloc(arg);
21302 const auto size_before_insert=insert_pos;
21303 #if in_debug || defined(ELC_CHECK_MEMORYS_ERROR)
21304 if(from_size<insert_pos)
21305 __debugbreak();//?
21306 #endif
21307 const auto size_after_insert=from_size-insert_pos;
21308 if constexpr(move.trivial<T>){
21309 realloc(arg,to_size);
21310 memmove(arg+size_before_insert+insert_size,arg+size_before_insert,size_after_insert*sizeof(T));
21311 }
21312 else{
21313 T*tmp=alloc<T>(to_size);
21314 if constexpr(!move.nothrow<T>){
21315 template_warning("the move of T was not noexcept,this may cause memory lack.");
21316 try{
21317 move[size_before_insert](note::from(arg),note::to(tmp));
21318 move[size_after_insert](note::from(arg+insert_pos),note::to(tmp+insert_pos+insert_size));
21319 }catch(...){
21320 free(tmp);
21321 throw;
21322 }
21323 }else{
21324 move[size_before_insert](note::from(arg),note::to(tmp));
21325 move[size_after_insert](note::from(arg+insert_pos),note::to(tmp+insert_pos+insert_size));
21326 }
21327 free(arg);
21328 arg=tmp;
21329 }
21330 struct result_t{
21331 size_t from_size;
21332 size_t to_size;
21333 size_t size_before_insert;
21334 size_t size_after_insert;
21335 size_t insert_pos;
21336 size_t insert_size;
21337 size_t end_grow_size()const noexcept{return to_size-from_size-insert_size;}
21338 T* origin_data_ptr(T*arg)const noexcept{return arg;}
21339 T* insert_data_ptr(T*arg)const noexcept{return arg+insert_pos;}
21340 T* end_growth_data_ptr(T*arg)const noexcept{return arg+to_size-end_grow_size();}
21341 } result{
21342 from_size,
21343 to_size,
21344 size_before_insert,
21345 size_after_insert,
21346 insert_pos,
21347 insert_size
21348 };
21349 return result;
21350 }
函数调用图:

◆ forward_alloc_size_cut()

template<typename T >
void elc::defs::memory::get_n::forward_alloc_size_cut ( T *&  arg,
size_t  to_size 
)
noexcept

向前减小数据块大小并转移原有实例的生命周期,但并不析构旧的实例

参数
arg原有数据块
to_size新的数据块大小

在文件 all_defs.cpp21430 行定义.

21430 {
21431 const auto from_size=get_size_of_alloc(arg);
21432 #if in_debug || defined(ELC_CHECK_MEMORYS_ERROR)
21433 if(to_size>from_size)
21434 __debugbreak();//?
21435 #endif
21436 const auto cut_size=from_size-to_size;
21437 if constexpr(move.trivial<T>){
21438 ::std::memmove(arg,add_const(arg+cut_size),to_size*sizeof(T));
21439 realloc(arg,to_size);
21440 }
21441 else{
21442 T*tmp=alloc<T>(to_size);
21443 if constexpr(!move.nothrow<T>){
21444 template_warning("the move of T was not noexcept,this may cause memory lack.");
21445 try{
21446 move[to_size](note::from(arg+cut_size),note::to(tmp));
21447 }catch(...){
21448 free(tmp);
21449 throw;
21450 }
21451 }else{
21452 move[to_size](note::from(arg+cut_size),note::to(tmp));
21453 }
21454 free(arg);
21455 arg=tmp;
21456 }
21457 }
constexpr const T add_const(T a) noexcept
对值追加const
函数调用图:
这是这个函数的调用关系图:

◆ forward_alloc_size_grow()

template<typename T >
void elc::defs::memory::get_n::forward_alloc_size_grow ( T *&  arg,
size_t  to_size 
)
noexcept

向前扩大数据块大小并转移原有实例的生命周期,但并不构造新的实例

参数
arg原有数据块
to_size新的数据块大小

在文件 all_defs.cpp21465 行定义.

21465 {
21466 const auto from_size=get_size_of_alloc(arg);
21467 #if in_debug || defined(ELC_CHECK_MEMORYS_ERROR)
21468 if(to_size<from_size)
21469 __debugbreak();//?
21470 #endif
21471 const auto grow_size=to_size-from_size;
21472 if constexpr(move.trivial<T>){
21473 realloc(arg,to_size);
21474 ::std::memmove(arg+grow_size,add_const(arg),from_size*sizeof(T));
21475 }
21476 else{
21477 T*tmp=alloc<T>(to_size);
21478 if constexpr(!move.nothrow<T>){
21479 template_warning("the move of T was not noexcept,this may cause memory lack.");
21480 try{
21481 move[from_size](note::from(arg),note::to(tmp+grow_size));
21482 }catch(...){
21483 free(tmp);
21484 throw;
21485 }
21486 }else{
21487 move[from_size](note::from(arg),note::to(tmp+grow_size));
21488 }
21489 free(arg);
21490 arg=tmp;
21491 }
21492 }
函数调用图:
这是这个函数的调用关系图:

◆ forward_alloc_size_grow_with_insert_uninitialized_data()

template<typename T >
auto elc::defs::memory::get_n::forward_alloc_size_grow_with_insert_uninitialized_data ( T *&  arg,
size_t  to_size,
size_t  insert_pos,
size_t  insert_size 
)
inlinenoexcept

在指定位置插入未初始化数据块并转移原有实例的生命周期,但并不构造新的实例 若有多余的大小,追加到前端

参数
arg原有数据块
to_size新的数据块大小
insert_pos插入位置
insert_size插入大小
返回
详细的操作信息

在文件 all_defs.cpp21505 行定义.

21505 {
21506 const auto from_size=get_size_of_alloc(arg);
21507 const auto grow_size=to_size-from_size;
21508 #if in_debug || defined(ELC_CHECK_MEMORYS_ERROR)
21509 if(grow_size<insert_size)
21510 __debugbreak();//?
21511 #endif
21512 const auto before_grow_size=grow_size-insert_size;
21513 const auto size_before_insert=insert_pos;
21514 const auto size_after_insert=from_size-insert_pos;
21515 if constexpr(move.trivial<T>){
21516 realloc(arg,to_size);
21517 const auto origin_data_ptr=arg+before_grow_size;
21518 ::std::memmove(origin_data_ptr+size_before_insert+insert_size,arg+size_before_insert,size_after_insert*sizeof(T));
21519 ::std::memmove(origin_data_ptr,arg,size_before_insert*sizeof(T));
21520 }
21521 else{
21522 T*tmp=alloc<T>(to_size);
21523 if constexpr(!move.nothrow<T>){
21524 template_warning("the move of T was not noexcept,this may cause memory lack.");
21525 try{
21526 const auto origin_data_ptr=tmp+before_grow_size;
21527 move[size_before_insert](note::from(arg),note::to(origin_data_ptr));
21528 move[size_after_insert](note::from(arg+size_before_insert),note::to(origin_data_ptr+size_before_insert+insert_size));
21529 }catch(...){
21530 free(tmp);
21531 throw;
21532 }
21533 }else{
21534 const auto origin_data_ptr=tmp+before_grow_size;
21535 move[size_before_insert](note::from(arg),note::to(origin_data_ptr));
21536 move[size_after_insert](note::from(arg+size_before_insert),note::to(origin_data_ptr+size_before_insert+insert_size));
21537 }
21538 free(arg);
21539 arg=tmp;
21540 }
21541 struct result_t{
21542 size_t from_size;
21543 size_t to_size;
21544 size_t before_grow_size;
21545 size_t size_before_insert;
21546 size_t size_after_insert;
21547 size_t insert_pos;
21548 size_t insert_size;
21549 T* origin_data_ptr(T*arg)const noexcept{return arg+before_grow_size;}
21550 T* insert_data_ptr(T*arg)const noexcept{return origin_data_ptr(arg)+insert_pos;}
21551 } result{
21552 from_size,
21553 to_size,
21554 before_grow_size,
21555 size_before_insert,
21556 size_after_insert,
21557 insert_pos,
21558 insert_size
21559 };
21560 return result;
21561 }
函数调用图:
这是这个函数的调用关系图:

◆ part_used_block_alloc_size_grow_with_insert_uninitialized_data()

template<typename T >
auto elc::defs::memory::get_n::part_used_block_alloc_size_grow_with_insert_uninitialized_data ( T *&  arg,
size_t  to_size,
size_t  insert_pos,
size_t  insert_size,
size_t  used_size 
)
inlinenoexcept

假设尾部有未使用的对象前提下,在指定位置插入未初始化数据块并转移原有实例的生命周期,允许新的参数描述已使用的对象多少,并不构造新的实例 若有多余的大小,追加到末尾

参数
arg原有数据块
to_size新的数据块大小
insert_pos插入位置
insert_size插入大小
used_size已使用的对象多少
返回
详细的操作信息

在文件 all_defs.cpp21364 行定义.

21364 {
21365 const auto from_size=get_size_of_alloc(arg);
21366 const auto size_before_insert=insert_pos;
21367 const auto size_after_insert=used_size-insert_pos;
21368 const auto unused_size_before_insert=from_size-used_size;
21369 const auto unused_size_after_insert=to_size-insert_size-used_size;
21370 if constexpr(move.trivial<T>){
21371 realloc(arg,to_size);
21372 //先移动插入末尾的元素
21373 memmove(arg+size_before_insert+insert_size,arg+insert_pos,size_after_insert*sizeof(T));
21374 //插入前的元素没有移动
21375 }
21376 else{
21377 T*tmp=alloc<T>(to_size);
21378 if constexpr(!move.nothrow<T>){
21379 template_warning("the move of T was not noexcept,this may cause memory lack.");
21380 try{
21381 move[size_after_insert](note::from(arg+insert_pos),note::to(tmp+insert_pos+insert_size));
21382 //这里我们需要移动插入前的元素因为这是新的空间
21383 move[size_before_insert](note::from(arg),note::to(tmp));
21384 }catch(...){
21385 free(tmp);
21386 throw;
21387 }
21388 }else{
21389 move[size_after_insert](note::from(arg+insert_pos),note::to(tmp+insert_pos+insert_size));
21390 //这里我们需要移动插入前的元素因为这是新的空间
21391 move[size_before_insert](note::from(arg),note::to(tmp));
21392 }
21393 free(arg);
21394 arg=tmp;
21395 }
21396 struct result_t{
21397 size_t from_size;
21398 size_t to_size;
21399 size_t unused_size_before_insert;
21400 size_t unused_size_after_insert;
21401 size_t used_size;
21402 size_t size_before_insert;
21403 size_t size_after_insert;
21404 size_t insert_pos;
21405 size_t insert_size;
21406 size_t end_grow_size()const noexcept{return to_size-from_size-insert_size;}
21407 T* origin_data_ptr(T*arg)const noexcept{return arg;}
21408 T* insert_data_ptr(T*arg)const noexcept{return arg+insert_pos;}
21409 T* end_growth_data_ptr(T*arg)const noexcept{return arg+to_size-used_size;}
21410 } result{
21411 from_size,
21412 to_size,
21413 unused_size_before_insert,
21414 unused_size_after_insert,
21415 used_size,
21416 size_before_insert,
21417 size_after_insert,
21418 insert_pos,
21419 insert_size
21420 };
21421 return result;
21422 }
函数调用图:
这是这个函数的调用关系图:

◆ part_used_block_forward_alloc_size_grow_with_insert_uninitialized_data()

template<typename T >
auto elc::defs::memory::get_n::part_used_block_forward_alloc_size_grow_with_insert_uninitialized_data ( T *&  arg,
size_t  to_size,
size_t  insert_pos,
size_t  insert_size,
size_t  used_size 
)
inlinenoexcept

假设头部有未使用的对象前提下,在指定位置插入未初始化数据块并转移原有实例的生命周期,允许新的参数描述已使用的对象多少,并不构造新的实例 若有多余的大小,追加到前端

参数
arg原有数据块
to_size新的数据块大小
insert_pos插入位置
insert_size插入大小
used_size已使用的对象多少
返回
详细的操作信息

在文件 all_defs.cpp21575 行定义.

21575 {
21576 const auto from_size=get_size_of_alloc(arg);//原有数据块大小
21577 const auto grow_size=to_size-from_size;//扩大的大小
21578 const auto used_size_after_insert=used_size+insert_size;//插入后的已使用大小
21579 const auto unused_size_after_insert=to_size-used_size_after_insert;//插入后的未使用大小
21580 const auto unused_size_before_insert=from_size-used_size;//插入前的未使用大小
21581
21582 const auto after_insert_size=from_size-insert_pos;//插入位置之后的数据块的大小
21583 const auto before_insert_size=insert_pos-unused_size_before_insert;//插入位置之前的数据块的大小
21584 insert_pos-=unused_size_before_insert;//插入位置
21585 if constexpr(move.trivial<T>){
21586 realloc(arg,to_size);
21587 const auto new_data_ptr=arg+unused_size_after_insert;
21588 const auto origin_data_ptr=arg+unused_size_before_insert;
21589 //先移动插入末尾的元素
21590 ::std::memmove(new_data_ptr+insert_pos+insert_size,origin_data_ptr+insert_pos,after_insert_size*sizeof(T));
21591 //再移动插入前的元素
21592 ::std::memmove(new_data_ptr,origin_data_ptr,before_insert_size*sizeof(T));
21593 }
21594 else{
21595 T*tmp=alloc<T>(to_size);
21596 const auto new_data_ptr=tmp+unused_size_after_insert;
21597 const auto origin_data_ptr=arg+unused_size_before_insert;
21598 if constexpr(!move.nothrow<T>){
21599 template_warning("the move of T was not noexcept,this may cause memory lack.");
21600 try{
21601 move[after_insert_size](note::from(origin_data_ptr+insert_pos),note::to(new_data_ptr+insert_pos+insert_size));
21602 move[before_insert_size](note::from(origin_data_ptr),note::to(new_data_ptr));
21603 }catch(...){
21604 free(tmp);
21605 throw;
21606 }
21607 }else{
21608 move[after_insert_size](note::from(origin_data_ptr+insert_pos),note::to(new_data_ptr+insert_pos+insert_size));
21609 move[before_insert_size](note::from(origin_data_ptr),note::to(new_data_ptr));
21610 }
21611 free(arg);
21612 arg=tmp;
21613 }
21614 struct result_t{
21615 size_t from_size;
21616 size_t to_size;
21617 size_t unused_size_before_insert;
21618 size_t unused_size_after_insert;
21619 size_t used_size_after_insert;
21620 size_t before_insert_size;
21621 size_t after_insert_size;
21622 size_t used_size;
21623 size_t grow_size;
21624 size_t insert_pos;
21625 size_t insert_size;
21626 T* new_data_ptr(T*arg)const noexcept{return arg+unused_size_after_insert;}
21627 T* origin_data_ptr(T*arg)const noexcept{return arg+unused_size_before_insert;}
21628 size_t before_grow_size()const noexcept{return grow_size+used_size-insert_size;}
21629 T* insert_data_ptr(T*arg)const noexcept{return arg+unused_size_after_insert+insert_pos;}
21630 } result{
21631 from_size,
21632 to_size,
21633 unused_size_before_insert,
21634 unused_size_after_insert,
21635 used_size_after_insert,
21636 before_insert_size,
21637 after_insert_size,
21638 used_size,
21639 grow_size,
21640 insert_pos,
21641 insert_size
21642 };
21643 return result;
21644 }
函数调用图:
这是这个函数的调用关系图:

变量说明

◆ copy_get

constexpr struct elc::defs::memory::get_n::copy_get_t elc::defs::memory::get_n::copy_get

◆ get

template<typename T >
constexpr get_t<T> elc::defs::memory::get_n::get {}
constexpr

在文件 all_defs.cpp21763 行定义.

21763{};

◆ get_forward_resize

constexpr struct elc::defs::memory::get_n::get_forward_resize_t elc::defs::memory::get_n::get_forward_resize

◆ get_resize

constexpr struct elc::defs::memory::get_n::get_resize_t elc::defs::memory::get_n::get_resize

◆ get_size_of_get

constexpr struct elc::defs::memory::get_n::get_size_of_get_t elc::defs::memory::get_n::get_size_of_get

◆ unget

constexpr struct elc::defs::memory::get_n::unget_t elc::defs::memory::get_n::unget