Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
steve02081504 committed Oct 29, 2023
1 parent 2381fad commit 1196000
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class base_stack_t:non_copyable{//基础容器,可用于hashtable
}
void move_top_to(this_t&a)noexcept{
_size--;
a.add(swap(_m,add_const(_m->_next)));
a.add(swap(_m,add_const_by_value(_m->_next)));
}
};

Expand Down
12 changes: 12 additions & 0 deletions parts/header_file/files/elc/_files/base_defs/cast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,33 @@ push_and_disable_msvc_warning(
/// 对值追加const
template<typename T>
force_inline constexpr const T add_const(T a)noexcept{return a;}
template<typename T>
force_inline constexpr const T add_const_by_value(T a)noexcept{return a;}
/// 对引用追加const
template<typename T>
force_inline constexpr const T&add_const(T&a)noexcept{return a;}
template<typename T>
force_inline constexpr const T&add_const_by_ref(T&a)noexcept{return a;}
/// 对引用移除const
template<typename T>
force_inline constexpr T&remove_const(const T&a)noexcept{return const_cast<T&>(a);}
template<typename T>
force_inline constexpr T&remove_const_by_ref(const T&a)noexcept{return const_cast<T&>(a);}
/// 对指针追加const
template<typename T>
force_inline constexpr const T*add_const(T*a)noexcept{return a;}
template<typename T>
force_inline constexpr const T*add_const_by_ptr(T*a)noexcept{return a;}
/// 对指针移除const
template<typename T>
force_inline constexpr T*remove_const(const T*a)noexcept{return const_cast<T*>(a);}
template<typename T>
force_inline constexpr T*remove_const_by_ptr(const T*a)noexcept{return const_cast<T*>(a);}
/// 对指针移除const
template<typename T>
force_inline constexpr T*launder_remove_const(const T*a)noexcept{return ::std::launder(remove_const(a));}
template<typename T>
force_inline constexpr T*launder_remove_const_by_ptr(const T*a)noexcept{return ::std::launder(remove_const(a));}
/// 向下转型至
template<typename T,typename U>
force_inline constexpr T down_cast(U a)noexcept{return static_cast<T>(a);}
Expand Down
10 changes: 5 additions & 5 deletions parts/header_file/test/elc-header-file-test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@
#define ELC_TEST_CHECK_MEMORY_LACK
#include <elc/core>
#include <elc/string>
#include <elc/lib_loader>
#include <elc/void_name>
//#include <elc/lib_loader>
//#include <elc/namespace>

#include <elc/code_realm>
#include <elc/void_name>

#if defined(_MSC_VER)
#define delete [[gsl::suppress(i.11,r.11)]]delete
#endif

void ste::stst(){
using namespace elc;
using namespace elc::defs;
::void ste::stst(){
using namespace elc::defs::core;
using elc::void;
{
Expand Down
6 changes: 4 additions & 2 deletions parts/header_file/test/elc-header-file-test/test_inline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#define ELC_TEST_CHECK_MEMORY_LACK
#include <elc/core>
#include <elc/string>
#include <elc/lib_loader>
#include <elc/void_name>
//#include <elc/lib_loader>
//#include <elc/namespace>

#include <elc/code_realm>
#include <elc/void_name>

0 comments on commit 1196000

Please sign in to comment.