Skip to content

Commit

Permalink
Merge pull request #31 from MacroModel/master
Browse files Browse the repository at this point in the history
fix parameters
  • Loading branch information
trcrsired authored Jan 12, 2024
2 parents fd54c2b + b31e3d7 commit 30b06d1
Show file tree
Hide file tree
Showing 24 changed files with 151 additions and 151 deletions.
8 changes: 4 additions & 4 deletions include/fast_io_core_impl/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace fast_io

struct error
{
using value_type = ::std::uintptr_t;
using value_type = ::std::size_t;
value_type domain{};
value_type code{};
};
Expand All @@ -30,10 +30,10 @@ template<typename T>
inline constexpr error_type_t<T> error_type{};

template<typename T>
concept error_domain = ::std::is_trivially_copyable_v<T> && sizeof(T)<=sizeof(::std::uintptr_t) &&
concept error_domain = ::std::is_trivially_copyable_v<T> && sizeof(T)<=sizeof(::std::size_t) &&
requires(error e,T t)
{
{domain_define(error_type<T>)}->::std::same_as<::std::uintptr_t>;
{domain_define(error_type<T>)}->::std::same_as<::std::size_t>;
{equivalent_define(error_type<T>,e,t)}->::std::same_as<bool>;
#if 0
{to_code_define(error_type<T>,e)}->::std::same_as<T>;
Expand All @@ -43,7 +43,7 @@ concept error_domain = ::std::is_trivially_copyable_v<T> && sizeof(T)<=sizeof(::
template<error_domain D>
inline constexpr bool is_domain(error e) noexcept
{
constexpr ::std::uintptr_t v{error_domain_define(error_type<D>)};
constexpr ::std::size_t v{error_domain_define(error_type<D>)};
return v==e.domain;
}

Expand Down
20 changes: 10 additions & 10 deletions include/fast_io_core_impl/integers/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ struct integer_alias_type_traits
template<typename inttype>
using integer_alias_type = typename integer_alias_type_traits<::std::remove_cvref_t<inttype>>::alias_type;

using uintptr_alias_type = ::fast_io::details::integer_alias_type<::std::uintptr_t>;
using uintptr_alias_type = ::fast_io::details::integer_alias_type<::std::size_t>;

template<typename inttype>
struct integer_full_alias_type_traits
Expand All @@ -254,7 +254,7 @@ struct integer_full_alias_type_traits
template<typename inttype>
using integer_full_alias_type = typename integer_full_alias_type_traits<::std::remove_cvref_t<inttype>>::alias_type;

using uintptr_full_alias_type = ::fast_io::details::integer_full_alias_type<::std::uintptr_t>;
using uintptr_full_alias_type = ::fast_io::details::integer_full_alias_type<::std::size_t>;

template<typename flt>
struct float_alias_type_traits
Expand Down Expand Up @@ -346,7 +346,7 @@ inline constexpr auto scalar_flags_int_cache(scalar_type t) noexcept
}
else if constexpr(::std::is_pointer_v<scalar_type_nocvref>)
{
return ::fast_io::manipulators::scalar_manip_t<cache,uintptr_full_alias_type>{static_cast<uintptr_full_alias_type>(::std::bit_cast<::std::uintptr_t>(t))};
return ::fast_io::manipulators::scalar_manip_t<cache,uintptr_full_alias_type>{static_cast<uintptr_full_alias_type>(::std::bit_cast<::std::size_t>(t))};
}
else if constexpr(::std::same_as<::fast_io::manipulators::member_function_pointer_holder_t,scalar_type_nocvref>)
{
Expand All @@ -358,7 +358,7 @@ inline constexpr auto scalar_flags_int_cache(scalar_type t) noexcept
}
else
{
return ::fast_io::manipulators::scalar_manip_t<cache,uintptr_full_alias_type>{static_cast<uintptr_full_alias_type>(::std::bit_cast<::std::uintptr_t>(::std::to_address(t)))};
return ::fast_io::manipulators::scalar_manip_t<cache,uintptr_full_alias_type>{static_cast<uintptr_full_alias_type>(::std::bit_cast<::std::size_t>(::std::to_address(t)))};
}

}
Expand Down Expand Up @@ -389,15 +389,15 @@ inline constexpr auto scalar_flags_int_cache(scalar_type t) noexcept
}
else if constexpr(::std::is_pointer_v<scalar_type_nocvref>)
{
return ::fast_io::manipulators::scalar_manip_t<cache,uintptr_alias_type>{static_cast<uintptr_alias_type>(::std::bit_cast<::std::uintptr_t>(t))};
return ::fast_io::manipulators::scalar_manip_t<cache,uintptr_alias_type>{static_cast<uintptr_alias_type>(::std::bit_cast<::std::size_t>(t))};
}
else if constexpr(::fast_io::details::has_scalar_manip_detail_tag<scalar_type>)
{
return ::fast_io::manipulators::scalar_manip_t<cache,typename scalar_type_nocvref::value_type>{t.reference};
}
else
{
return ::fast_io::manipulators::scalar_manip_t<cache,uintptr_alias_type>{static_cast<uintptr_alias_type>(::std::bit_cast<::std::uintptr_t>(::std::to_address(t)))};
return ::fast_io::manipulators::scalar_manip_t<cache,uintptr_alias_type>{static_cast<uintptr_alias_type>(::std::bit_cast<::std::size_t>(::std::to_address(t)))};
}
}
}
Expand Down Expand Up @@ -573,7 +573,7 @@ template<bool uppercase=false,typename scalar_type>
requires (::std::is_function_v<scalar_type>)
inline constexpr auto funcvw(scalar_type *t) noexcept
{
return ::fast_io::details::scalar_flags_int_cache<::fast_io::details::base_mani_flags_cache<16,uppercase,true,true,false>>(::std::bit_cast<::std::uintptr_t>(t));
return ::fast_io::details::scalar_flags_int_cache<::fast_io::details::base_mani_flags_cache<16,uppercase,true,true,false>>(::std::bit_cast<::std::size_t>(t));
}

template<bool uppercase=false,typename scalar_type>
Expand Down Expand Up @@ -1445,8 +1445,8 @@ bool uppercase,
bool full>
inline constexpr ::std::size_t nullptr_print_optimization_call_size_impl() noexcept
{
::fast_io::freestanding::array<char_type,print_integer_reserved_size_cache<base,showbase,showpos,::std::uintptr_t>> arr;
auto res{print_reserve_integral_define<base,showbase,uppercase_showbase,showpos,uppercase,full>(arr.data(),::std::uintptr_t{})};
::fast_io::freestanding::array<char_type,print_integer_reserved_size_cache<base,showbase,showpos,::std::size_t>> arr;
auto res{print_reserve_integral_define<base,showbase,uppercase_showbase,showpos,uppercase,full>(arr.data(),::std::size_t{})};
return static_cast<::std::size_t>(res-arr.data());
}

Expand All @@ -1471,7 +1471,7 @@ inline constexpr auto nullptr_print_optimization_call_impl() noexcept
{
constexpr ::std::size_t sz{nullptr_print_optimization_call_size_cache<char_type,base,showbase,uppercase_showbase,showpos,uppercase,full>};
::fast_io::freestanding::array<char_type,sz> arr{};
auto res{print_reserve_integral_define<base,showbase,uppercase_showbase,showpos,uppercase,full>(arr.data(),::std::uintptr_t{})};
auto res{print_reserve_integral_define<base,showbase,uppercase_showbase,showpos,uppercase,full>(arr.data(),::std::size_t{})};
return arr;
}

Expand Down
14 changes: 7 additions & 7 deletions include/fast_io_core_impl/parse_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,25 @@ inline constexpr char_type* print_reserve_define(io_reserve_type_t<char_type,par
return details::print_reserve_parse_code_impl(iter,code);
}

inline constexpr ::std::uintptr_t domain_define(error_type_t<parse_code>) noexcept
inline constexpr ::std::size_t domain_define(error_type_t<parse_code>) noexcept
{
if constexpr(sizeof(::std::uintptr_t)<=sizeof(::std::uint_least16_t))
if constexpr(sizeof(::std::size_t)<=sizeof(::std::uint_least16_t))
return 19339u;
else if constexpr(sizeof(::std::uintptr_t)<=sizeof(::std::uint_least32_t))
else if constexpr(sizeof(::std::size_t)<=sizeof(::std::uint_least32_t))
return 2666707100u;
else
return 17020429607921007685ULL;
}

inline constexpr ::std::uintptr_t parse_domain_value{domain_define(error_type<parse_code>)};
inline constexpr ::std::size_t parse_domain_value{domain_define(error_type<parse_code>)};

[[noreturn]] inline void throw_parse_code([[maybe_unused]] parse_code code)
{
#ifdef __cpp_exceptions
#if defined(_MSC_VER) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS == 0)
fast_terminate();
#else
throw ::fast_io::error{parse_domain_value,static_cast<::std::uintptr_t>(static_cast<char8_t>(code))};
throw ::fast_io::error{parse_domain_value,static_cast<::std::size_t>(static_cast<char8_t>(code))};
#endif
#else
fast_terminate();
Expand All @@ -123,7 +123,7 @@ inline constexpr ::std::uintptr_t parse_domain_value{domain_define(error_type<pa
namespace details
{

inline constexpr bool parse_code_equivalent_impl(::std::uintptr_t domain,::std::uintptr_t code,::std::uintptr_t e) noexcept
inline constexpr bool parse_code_equivalent_impl(::std::size_t domain,::std::size_t code,::std::size_t e) noexcept
{
return domain==parse_domain_value&&code==e;
}
Expand All @@ -132,7 +132,7 @@ inline constexpr bool parse_code_equivalent_impl(::std::uintptr_t domain,::std::

inline constexpr bool equivalent_define(error_type_t<parse_code>,error e,parse_code code) noexcept
{
return ::fast_io::details::parse_code_equivalent_impl(e.domain,e.code,static_cast<::std::uintptr_t>(static_cast<char8_t>(code)));
return ::fast_io::details::parse_code_equivalent_impl(e.domain,e.code,static_cast<::std::size_t>(static_cast<char8_t>(code)));
}

}
8 changes: 4 additions & 4 deletions include/fast_io_driver/posix_iconv_impl/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class posix_iconv_io_observer
{
public:
using native_handle_type = iconv_t;
iconv_t cd{::std::bit_cast<iconv_t>(static_cast<uintptr_t>(-1))};
iconv_t cd{::std::bit_cast<iconv_t>(static_cast<size_t>(-1))};

constexpr auto& native_handle() noexcept
{
Expand All @@ -22,14 +22,14 @@ class posix_iconv_io_observer
constexpr iconv_t release() noexcept
{
auto temp{cd};
cd = ::std::bit_cast<iconv_t>(static_cast<uintptr_t>(-1));
cd = ::std::bit_cast<iconv_t>(static_cast<size_t>(-1));
return temp;
}
};

struct iconv_deco_t
{
iconv_t cd{::std::bit_cast<iconv_t>(static_cast<uintptr_t>(-1))};
iconv_t cd{::std::bit_cast<iconv_t>(static_cast<size_t>(-1))};
char buffer[32]{};
::std::size_t len{};
iconv_deco_t(posix_iconv_io_observer piiob) noexcept:cd(piiob.cd){}
Expand Down Expand Up @@ -189,7 +189,7 @@ namespace details
inline iconv_t my_iconv_open(char const* tocode,char const* fromcode)
{
auto cd{iconv_open(tocode,fromcode)};
if(cd==::std::bit_cast<iconv_t>(static_cast<uintptr_t>(-1)))
if(cd==::std::bit_cast<iconv_t>(static_cast<size_t>(-1)))
throw_posix_error();
return cd;
}
Expand Down
8 changes: 4 additions & 4 deletions include/fast_io_driver/win32_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ inline constexpr win32_memory_page_protect& operator^=(win32_memory_page_protect

struct win32_memory_basic_information
{
::std::uintptr_t base_address{};
::std::uintptr_t allocation_base{};
::std::size_t base_address{};
::std::size_t allocation_base{};
win32_memory_page_protect allocation_protect{};
::std::size_t region_size{};
::std::uint_least32_t state{};
Expand Down Expand Up @@ -215,7 +215,7 @@ class basic_win32_memory_io_observer
{
public:
using native_handle_type = void*;
using base_address_type = ::std::uintptr_t;
using base_address_type = ::std::size_t;
using char_type = ch_type;
native_handle_type handle{};
base_address_type base_addr{};
Expand Down Expand Up @@ -469,7 +469,7 @@ template<::std::integral char_type>
class win32_virtual_protect_guard
{
void* process_handle{};
::std::uintptr_t address{};
::std::size_t address{};
::std::size_t region_size{};
win32_memory_page_protect oprotect{};
public:
Expand Down
4 changes: 2 additions & 2 deletions include/fast_io_freestanding_impl/cond.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ concept cond_value_transferable =
#if (defined(_WIN32) && !defined(__WINE__)) || defined(__CYGWIN__)
sizeof(::std::remove_cvref_t<T1>) <= 8u
#else
sizeof(::std::remove_cvref_t<T1>) <= (sizeof(::std::uintptr_t) * 2)
sizeof(::std::remove_cvref_t<T1>) <= (sizeof(::std::size_t) * 2)
#endif
;
}
Expand Down Expand Up @@ -77,7 +77,7 @@ concept cond_transferable_value =
#if (defined(_WIN32) && !defined(__WINE__)) || defined(__CYGWIN__)
sizeof(::fast_io::manipulators::condition<T1, T2>) <= 8u
#else
sizeof(::fast_io::manipulators::condition<T1, T2>) <= (sizeof(::std::uintptr_t) * 2)
sizeof(::fast_io::manipulators::condition<T1, T2>) <= (sizeof(::std::size_t) * 2)
#endif
;
}
Expand Down
20 changes: 10 additions & 10 deletions include/fast_io_freestanding_impl/width.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ inline constexpr auto width(scalar_placement placement,T&& t,::std::size_t n) no
#if (defined(_WIN32)&&!defined(__WINE__)) || defined(__CYGWIN__)
sizeof(noref)<=8u
#else
sizeof(noref)<=(sizeof(::std::uintptr_t)*2)
sizeof(noref)<=(sizeof(::std::size_t)*2)
#endif
)
{
Expand All @@ -43,7 +43,7 @@ inline constexpr auto width(scalar_placement placement,T&& t,::std::size_t n,cha
#if (defined(_WIN32)&&!defined(__WINE__)) || defined(__CYGWIN__)
sizeof(noref)<=8u
#else
sizeof(noref)<=(sizeof(::std::uintptr_t)*2)
sizeof(noref)<=(sizeof(::std::size_t)*2)
#endif
)

Expand All @@ -66,7 +66,7 @@ inline constexpr auto left(T&& t,::std::size_t n) noexcept
#if (defined(_WIN32)&&!defined(__WINE__)) || defined(__CYGWIN__)
sizeof(noref)<=8u
#else
sizeof(noref)<=(sizeof(::std::uintptr_t)*2)
sizeof(noref)<=(sizeof(::std::size_t)*2)
#endif
)
{
Expand All @@ -90,7 +90,7 @@ inline constexpr auto middle(T&& t,::std::size_t n) noexcept
#if (defined(_WIN32)&&!defined(__WINE__)) || defined(__CYGWIN__)
sizeof(noref)<=8u
#else
sizeof(noref)<=(sizeof(::std::uintptr_t)*2)
sizeof(noref)<=(sizeof(::std::size_t)*2)
#endif
)
{
Expand All @@ -114,7 +114,7 @@ inline constexpr auto right(T&& t,::std::size_t n) noexcept
#if (defined(_WIN32)&&!defined(__WINE__)) || defined(__CYGWIN__)
sizeof(noref)<=8u
#else
sizeof(noref)<=(sizeof(::std::uintptr_t)*2)
sizeof(noref)<=(sizeof(::std::size_t)*2)
#endif
)
{
Expand All @@ -139,7 +139,7 @@ inline constexpr auto internal(T&& t,::std::size_t n) noexcept
#if (defined(_WIN32)&&!defined(__WINE__)) || defined(__CYGWIN__)
sizeof(noref)<=8u
#else
sizeof(noref)<=(sizeof(::std::uintptr_t)*2)
sizeof(noref)<=(sizeof(::std::size_t)*2)
#endif
)
{
Expand All @@ -164,7 +164,7 @@ inline constexpr auto left(T&& t,::std::size_t n,char_type ch) noexcept
#if (defined(_WIN32)&&!defined(__WINE__)) || defined(__CYGWIN__)
sizeof(noref)<=8u
#else
sizeof(noref)<=(sizeof(::std::uintptr_t)*2)
sizeof(noref)<=(sizeof(::std::size_t)*2)
#endif
)
{
Expand All @@ -188,7 +188,7 @@ inline constexpr auto middle(T&& t,::std::size_t n,char_type ch) noexcept
#if (defined(_WIN32)&&!defined(__WINE__)) || defined(__CYGWIN__)
sizeof(noref)<=8u
#else
sizeof(noref)<=(sizeof(::std::uintptr_t)*2)
sizeof(noref)<=(sizeof(::std::size_t)*2)
#endif
)
{
Expand All @@ -212,7 +212,7 @@ inline constexpr auto right(T&& t,::std::size_t n,char_type ch) noexcept
#if (defined(_WIN32)&&!defined(__WINE__)) || defined(__CYGWIN__)
sizeof(noref)<=8u
#else
sizeof(noref)<=(sizeof(::std::uintptr_t)*2)
sizeof(noref)<=(sizeof(::std::size_t)*2)
#endif
)
{
Expand All @@ -236,7 +236,7 @@ inline constexpr auto internal(T&& t,::std::size_t n,char_type ch) noexcept
#if (defined(_WIN32)&&!defined(__WINE__)) || defined(__CYGWIN__)
sizeof(noref)<=8u
#else
sizeof(noref)<=(sizeof(::std::uintptr_t)*2)
sizeof(noref)<=(sizeof(::std::size_t)*2)
#endif
)
{
Expand Down
2 changes: 1 addition & 1 deletion include/fast_io_hosted/filesystem/nt_at.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ inline void native_unlinkat(nt_at_entry ent,path_type const& path,native_at_flag
}

template<::fast_io::constructible_to_os_c_str path_type>
inline void native_fchownat(nt_at_entry,path_type&&,::std::uintptr_t,::std::uintptr_t,[[maybe_unused]] nt_at_flags flags=nt_at_flags::symlink_nofollow)
inline void native_fchownat(nt_at_entry,path_type&&,::std::size_t,::std::size_t,[[maybe_unused]] nt_at_flags flags=nt_at_flags::symlink_nofollow)
{
//windows does not use POSIX user group system. stub it and it is perfectly fine. But nt_fchownat,zw_fchownat will not be provided since they do not exist.
}
Expand Down
10 changes: 5 additions & 5 deletions include/fast_io_hosted/platforms/nt/nt_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ struct nt_code
::std::uint_least32_t ntstatus{};
};

inline constexpr ::std::uintptr_t domain_define(error_type_t<nt_code>) noexcept
inline constexpr ::std::size_t domain_define(error_type_t<nt_code>) noexcept
{
if constexpr(sizeof(::std::uintptr_t)<=sizeof(::std::uint_least16_t))
if constexpr(sizeof(::std::size_t)<=sizeof(::std::uint_least16_t))
return 63612u;
else if constexpr(sizeof(::std::uintptr_t)<=sizeof(::std::uint_least32_t))
else if constexpr(sizeof(::std::size_t)<=sizeof(::std::uint_least32_t))
return 3776340491u;
else
return 17311375720795711021ULL;
}

inline constexpr ::std::uintptr_t nt_domain_value{domain_define(error_type<nt_code>)};
inline constexpr ::std::size_t nt_domain_value{domain_define(error_type<nt_code>)};

[[noreturn]] inline void throw_nt_error([[maybe_unused]] ::std::uint_least32_t err)
{
#ifdef __cpp_exceptions
#if defined(_MSC_VER) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS == 0)
fast_terminate();
#else
throw ::fast_io::error{nt_domain_value,static_cast<::std::uintptr_t>(err)};
throw ::fast_io::error{nt_domain_value,static_cast<::std::size_t>(err)};
#endif
#else
fast_terminate();
Expand Down
Loading

0 comments on commit 30b06d1

Please sign in to comment.