From 31a95dcc37a30a736aad062fed98cfa7374561d3 Mon Sep 17 00:00:00 2001 From: trcrsired Date: Tue, 23 Dec 2025 22:28:10 +0800 Subject: [PATCH 1/6] ignore __wasi_sched_yield()'s warning --- include/fast_io_hosted/threads/thread/wasi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fast_io_hosted/threads/thread/wasi.h b/include/fast_io_hosted/threads/thread/wasi.h index 8f555853..529d135c 100644 --- a/include/fast_io_hosted/threads/thread/wasi.h +++ b/include/fast_io_hosted/threads/thread/wasi.h @@ -270,7 +270,7 @@ inline #endif void yield() noexcept { - __wasi_sched_yield(); + (void)__wasi_sched_yield(); } } // namespace this_thread From 1cc311eb3e8ba1343495379ecae4e7558f19ca2e Mon Sep 17 00:00:00 2001 From: trcrsired Date: Fri, 26 Dec 2025 23:26:13 +0800 Subject: [PATCH 2/6] Add experimental fieldptrvw --- include/fast_io_core_impl/integers/impl.h | 8 +++++++ tests/0011.manipulators/fieldptrvw.cc | 28 +++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/0011.manipulators/fieldptrvw.cc diff --git a/include/fast_io_core_impl/integers/impl.h b/include/fast_io_core_impl/integers/impl.h index 00082036..43ecfacf 100644 --- a/include/fast_io_core_impl/integers/impl.h +++ b/include/fast_io_core_impl/integers/impl.h @@ -625,6 +625,14 @@ inline constexpr auto funcvw(scalar_type *t) noexcept ::fast_io::details::base_mani_flags_cache<16, uppercase, true, true, false>>(::std::bit_cast<::std::size_t>(t)); } +template + requires(::std::is_member_object_pointer_v) +inline constexpr auto fieldptrvw(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::size_t>(t)); +} + template requires(::std::is_member_function_pointer_v && (sizeof(scalar_type) % sizeof(::std::size_t) == 0)) inline constexpr auto methodvw(scalar_type t) noexcept diff --git a/tests/0011.manipulators/fieldptrvw.cc b/tests/0011.manipulators/fieldptrvw.cc new file mode 100644 index 00000000..cf795e52 --- /dev/null +++ b/tests/0011.manipulators/fieldptrvw.cc @@ -0,0 +1,28 @@ +#include + +struct S +{ + int x; + double y; + int z; +}; +struct A +{ + int a; +}; +struct B +{ + int b; +}; +struct C : A, B +{}; // multiple inheritance + +int main() +{ + using namespace ::fast_io::iomnp; + println("&B::b = ", fieldptrvw(&B::b), "\n" + "&C::b = ", + fieldptrvw(&C::b), "\n" + "&S::z = ", + fieldptrvw(&S::z)); +} From 606aed20e9813d0136611a343be0c6e4618fd45e Mon Sep 17 00:00:00 2001 From: trcrsired Date: Fri, 26 Dec 2025 23:38:48 +0800 Subject: [PATCH 3/6] fieldptrvw neeeds special treat for msvc abi --- include/fast_io_core_impl/integers/impl.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/fast_io_core_impl/integers/impl.h b/include/fast_io_core_impl/integers/impl.h index 43ecfacf..a517075a 100644 --- a/include/fast_io_core_impl/integers/impl.h +++ b/include/fast_io_core_impl/integers/impl.h @@ -629,8 +629,15 @@ template requires(::std::is_member_object_pointer_v) inline constexpr auto fieldptrvw(scalar_type t) noexcept { + using fieldptruinttype = +#ifdef _MSC_VER + ::std::uint_least32_t +#else + ::std::size_t +#endif + ; 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)); + ::fast_io::details::base_mani_flags_cache<16, uppercase, true, true, false>>(::std::bit_cast(t)); } template From f12a4ad5dc0da36b30ff92d1d76425cfd21197cc Mon Sep 17 00:00:00 2001 From: trcrsired Date: Fri, 26 Dec 2025 23:41:52 +0800 Subject: [PATCH 4/6] use constexpr variable in fieldptrvw to avoid as less annoying for macros caused by msvc abi detection --- include/fast_io_core_impl/integers/impl.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/fast_io_core_impl/integers/impl.h b/include/fast_io_core_impl/integers/impl.h index a517075a..c7ca9f0e 100644 --- a/include/fast_io_core_impl/integers/impl.h +++ b/include/fast_io_core_impl/integers/impl.h @@ -629,15 +629,13 @@ template requires(::std::is_member_object_pointer_v) inline constexpr auto fieldptrvw(scalar_type t) noexcept { - using fieldptruinttype = + constexpr bool ismsvcabi{ #ifdef _MSC_VER - ::std::uint_least32_t -#else - ::std::size_t + true #endif - ; + }; return ::fast_io::details::scalar_flags_int_cache< - ::fast_io::details::base_mani_flags_cache<16, uppercase, true, true, false>>(::std::bit_cast(t)); + ::fast_io::details::base_mani_flags_cache<16, uppercase, true, true, false>>(::std::bit_cast<::std::conditional_t>(t)); } template From 127b4b762d53fc1b2182a65a9e2f01700a12f097 Mon Sep 17 00:00:00 2001 From: trcrsired Date: Fri, 26 Dec 2025 23:47:08 +0800 Subject: [PATCH 5/6] the example should contain fieldptrvw --- examples/0003.manipulators/pointer.cc | 117 +++++++++++++++++--------- 1 file changed, 78 insertions(+), 39 deletions(-) diff --git a/examples/0003.manipulators/pointer.cc b/examples/0003.manipulators/pointer.cc index 1c5cbca6..0cef077d 100644 --- a/examples/0003.manipulators/pointer.cc +++ b/examples/0003.manipulators/pointer.cc @@ -13,6 +13,7 @@ struct A virtual void f() noexcept {} }; + struct B { virtual void g() noexcept @@ -23,59 +24,97 @@ struct C : A, B { }; +struct S +{ + int x; + double y; + int z; +}; + +struct VA +{ + int a; +}; + +struct VB : virtual VA +{ + int b; +}; + using namespace fast_io::io; -void foo(){} +void foo() +{} int main() { using namespace fast_io::mnp; + int fd{3}; int *ptr{::std::addressof(fd)}; - char const *ptr2 = "hello"; void (C::*downcptr)() noexcept = &B::g; - println("funcvw(foo):", funcvw(foo), - "\n" - "pointervw(ptr):", - pointervw(ptr), - "\n" - "handlevw(fd):", - handlevw(fd), - "\n" - "handlevw(ptr):", - handlevw(ptr), - "\n" - "pointervw(ptr2):", - pointervw(ptr2), - "\n" - "dec(pointervw(ptr2)):", - dec(pointervw(ptr2)), - "\n" - "os_c_str(ptr2):", - os_c_str(ptr2), - "\n" - "methodvw(&dummy_class::dummy_method):", - methodvw(&dummy_class::dummy_method), - "\n" - "dec(methodvw(&dummy_class::dummy_method)):", - dec(methodvw(&dummy_class::dummy_method)), - "\n" - "methodvw(downcptr):", - methodvw(downcptr)); + println( + "funcvw(foo):", funcvw(foo), + "\n" + "pointervw(ptr):", + pointervw(ptr), + "\n" + "handlevw(fd):", + handlevw(fd), + "\n" + "handlevw(ptr):", + handlevw(ptr), + "\n" + "pointervw(ptr2):", + pointervw(ptr2), + "\n" + "dec(pointervw(ptr2)):", + dec(pointervw(ptr2)), + "\n" + "os_c_str(ptr2):", + os_c_str(ptr2), + "\n" + "methodvw(&dummy_class::dummy_method):", + methodvw(&dummy_class::dummy_method), + "\n" + "dec(methodvw(&dummy_class::dummy_method)):", + dec(methodvw(&dummy_class::dummy_method)), + "\n" + "methodvw(downcptr):", + methodvw(downcptr), + "\n" + "fieldptrvw(&S::x):", + fieldptrvw(&S::x), + "\n" + "fieldptrvw(&S::y):", + fieldptrvw(&S::y), + "\n" + "fieldptrvw(&S::z):", + fieldptrvw(&S::z), + "\n" + "fieldptrvw(&VB::b):", + fieldptrvw(&VB::b), + "\n" + "fieldptrvw(&VA::a):", + fieldptrvw(&VA::a)); } - /* -funcvw(foo):0x00007ff75abf27c0 -pointervw(ptr):0x000000c232d0fa9c +funcvw(foo):0x0000000102368570 +pointervw(ptr):0x000000016da96e1c handlevw(fd):3 -handlevw(ptr):0x000000c232d0fa9c -pointervw(ptr2):0x00007ff75abf4540 -dec(pointervw(ptr2)):140700356134208 +handlevw(ptr):0x000000016da96e1c +pointervw(ptr2):0x0000000102369f0c +dec(pointervw(ptr2)):4332101388 os_c_str(ptr2):hello -methodvw(&dummy_class::dummy_method):0x00007ff75abf34b0+0x0 -dec(methodvw(&dummy_class::dummy_method)):140700356129968+0 -methodvw(downcptr):0x0000000000000001+0x8 +methodvw(&dummy_class::dummy_method):0x0000000102369400+0x0 +dec(methodvw(&dummy_class::dummy_method)):4332098560+0 +methodvw(downcptr):0x0000000000000000+0x11 +fieldptrvw(&S::x):0x0000000000000000 +fieldptrvw(&S::y):0x0000000000000008 +fieldptrvw(&S::z):0x0000000000000010 +fieldptrvw(&VB::b):0x0000000000000008 +fieldptrvw(&VA::a):0x0000000000000000 */ From 67f8969fa46781c520a1db183b214bba30bf0648 Mon Sep 17 00:00:00 2001 From: trcrsired Date: Sat, 27 Dec 2025 00:33:35 +0800 Subject: [PATCH 6/6] fieldptrvw on msvc abi is super annoying because it can alias to multiple types --- include/fast_io_core_impl/integers/impl.h | 27 +++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/include/fast_io_core_impl/integers/impl.h b/include/fast_io_core_impl/integers/impl.h index c7ca9f0e..15a7721f 100644 --- a/include/fast_io_core_impl/integers/impl.h +++ b/include/fast_io_core_impl/integers/impl.h @@ -629,13 +629,26 @@ template requires(::std::is_member_object_pointer_v) inline constexpr auto fieldptrvw(scalar_type t) noexcept { - constexpr bool ismsvcabi{ -#ifdef _MSC_VER - true -#endif - }; - return ::fast_io::details::scalar_flags_int_cache< - ::fast_io::details::base_mani_flags_cache<16, uppercase, true, true, false>>(::std::bit_cast<::std::conditional_t>(t)); + if constexpr (sizeof(t) == sizeof(::fast_io::manipulators::member_function_pointer_holder_t)) + { + return ::fast_io::details::scalar_flags_int_cache< + ::fast_io::details::base_mani_flags_cache<16, uppercase, true, true, false>>( + ::std::bit_cast<::fast_io::manipulators::member_function_pointer_holder_t>(t)); + } + else + { + using equivalentsizetype = ::std::conditional_t< + sizeof(scalar_type) == sizeof(::std::size_t), ::std::size_t, + ::std::conditional_t>>>; + return ::fast_io::details::scalar_flags_int_cache< + ::fast_io::details::base_mani_flags_cache<16, uppercase, true, true, false>>(::std::bit_cast(t)); + } } template