From 922fe4b5182344e358c67addf4fa912a4947e86d Mon Sep 17 00:00:00 2001 From: SidneyCogdill Date: Sun, 11 May 2025 06:23:08 +0000 Subject: [PATCH 01/28] Separate macro definitions and add cppm files --- CMakeLists.txt | 39 +- .../proxy_invocation_benchmark_context.h | 2 +- benchmarks/proxy_management_benchmark.cpp | 2 +- docs/PRO_DEF_FREE_AS_MEM_DISPATCH.md | 2 +- docs/PRO_DEF_FREE_DISPATCH.md | 2 +- docs/PRO_DEF_MEM_DISPATCH.md | 2 +- docs/access_proxy.md | 2 +- docs/allocate_proxy.md | 2 +- docs/allocate_proxy_shared.md | 2 +- docs/basic_facade_builder.md | 2 +- docs/basic_facade_builder/add_convention.md | 2 +- docs/basic_facade_builder/add_facade.md | 2 +- docs/basic_facade_builder/add_reflection.md | 2 +- docs/basic_facade_builder/build.md | 2 +- docs/basic_facade_builder/restrict_layout.md | 2 +- docs/basic_facade_builder/support_copy.md | 2 +- .../support_destruction.md | 2 +- docs/basic_facade_builder/support_format.md | 2 +- .../support_relocation.md | 2 +- docs/basic_facade_builder/support_rtti.md | 2 +- .../support_rtti/proxy_cast.md | 2 +- .../support_rtti/proxy_typeid.md | 2 +- docs/basic_facade_builder/support_view.md | 2 +- docs/basic_facade_builder/support_weak.md | 2 +- docs/explicit_conversion_dispatch.md | 2 +- docs/facade_aware_overload_t.md | 2 +- docs/implicit_conversion_dispatch.md | 2 +- docs/inplace_proxiable_target.md | 2 +- docs/make_proxy.md | 2 +- docs/make_proxy_inplace.md | 2 +- docs/make_proxy_shared.md | 2 +- docs/make_proxy_view.md | 2 +- docs/msft_lib_proxy.md | 2 +- docs/operator_dispatch.md | 2 +- docs/proxiable.md | 2 +- docs/proxiable_target.md | 2 +- docs/proxy.md | 2 +- docs/proxy/constructor.md | 2 +- docs/proxy/destructor.md | 2 +- docs/proxy/emplace.md | 2 +- docs/proxy/friend_operator_equality.md | 2 +- docs/proxy/friend_swap.md | 2 +- docs/proxy/indirection.md | 2 +- docs/proxy/operator_bool.md | 2 +- docs/proxy/reset.md | 2 +- docs/proxy_invoke.md | 2 +- docs/proxy_reflect.md | 2 +- docs/proxy_view.md | 2 +- docs/weak_dispatch.md | 2 +- docs/weak_proxy.md | 2 +- include/proxy/details/proxy_impl.h | 2513 ++++++++++++++++ include/proxy/details/proxy_impl_macros.h | 202 ++ include/proxy/proxy.cppm | 84 + include/proxy/proxy.h | 1 + proxy_fmt.h => include/proxy/proxy_fmt.h | 0 include/proxy/proxy_interface.cppm | 10 + include/proxy/proxy_macros.h | 1 + proxy.h | 2550 ----------------- tests/CMakeLists.txt | 2 + tests/cpp20_modules/CMakeLists.txt | 15 + tests/cpp20_modules/foo.cpp | 26 + tests/cpp20_modules/impl.cpp | 5 + tests/cpp20_modules/main.cpp | 14 + .../freestanding/proxy_freestanding_tests.cpp | 2 +- tests/proxy_creation_tests.cpp | 4 +- tests/proxy_dispatch_tests.cpp | 2 +- tests/proxy_fmt_format_tests.cpp | 4 +- tests/proxy_format_tests.cpp | 2 +- tests/proxy_integration_tests.cpp | 2 +- tests/proxy_invocation_tests.cpp | 2 +- tests/proxy_lifetime_tests.cpp | 4 +- tests/proxy_reflection_tests.cpp | 4 +- tests/proxy_regression_tests.cpp | 2 +- tests/proxy_rtti_tests.cpp | 2 +- tests/proxy_traits_tests.cpp | 4 +- tests/proxy_view_tests.cpp | 4 +- tests/utils.h | 1 + 77 files changed, 2974 insertions(+), 2625 deletions(-) create mode 100644 include/proxy/details/proxy_impl.h create mode 100644 include/proxy/details/proxy_impl_macros.h create mode 100644 include/proxy/proxy.cppm create mode 100644 include/proxy/proxy.h rename proxy_fmt.h => include/proxy/proxy_fmt.h (100%) create mode 100644 include/proxy/proxy_interface.cppm create mode 100644 include/proxy/proxy_macros.h delete mode 100644 proxy.h create mode 100644 tests/cpp20_modules/CMakeLists.txt create mode 100644 tests/cpp20_modules/foo.cpp create mode 100644 tests/cpp20_modules/impl.cpp create mode 100644 tests/cpp20_modules/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d303632..5eb0d86f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,42 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.28) project(msft_proxy VERSION 3.3.0 LANGUAGES CXX) -add_library(msft_proxy INTERFACE) -target_compile_features(msft_proxy INTERFACE cxx_std_20) -target_include_directories(msft_proxy INTERFACE $ +add_library(msft_proxy) + +target_sources(msft_proxy + PUBLIC + FILE_SET CXX_MODULES + TYPE CXX_MODULES + BASE_DIRS include + FILES + include/proxy/proxy.cppm + include/proxy/proxy_interface.cppm +) + +target_sources(msft_proxy + PUBLIC + FILE_SET public_headers + TYPE HEADERS + BASE_DIRS include + FILES + include/proxy/proxy.h + include/proxy/proxy_macros.h + include/proxy/proxy_fmt.h + include/proxy/details/proxy_impl.h + include/proxy/details/proxy_impl_macros.h +) + +target_compile_features(msft_proxy PUBLIC cxx_std_20) +target_include_directories(msft_proxy PUBLIC $ $) # install and export the project. project name - proxy include(GNUInstallDirs) install(TARGETS msft_proxy - EXPORT proxyConfig) -install(FILES proxy.h proxy_fmt.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/proxy) + EXPORT proxyConfig + FILE_SET CXX_MODULES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILE_SET public_headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) install(EXPORT proxyConfig DESTINATION ${CMAKE_INSTALL_DATADIR}/proxy) export(TARGETS msft_proxy FILE proxyConfig.cmake) include(CMakePackageConfigHelpers) diff --git a/benchmarks/proxy_invocation_benchmark_context.h b/benchmarks/proxy_invocation_benchmark_context.h index 5f749f0d..83d94750 100644 --- a/benchmarks/proxy_invocation_benchmark_context.h +++ b/benchmarks/proxy_invocation_benchmark_context.h @@ -4,7 +4,7 @@ #include #include -#include "proxy.h" +#include PRO_DEF_MEM_DISPATCH(MemFun, Fun); diff --git a/benchmarks/proxy_management_benchmark.cpp b/benchmarks/proxy_management_benchmark.cpp index ce7b2501..273576a9 100644 --- a/benchmarks/proxy_management_benchmark.cpp +++ b/benchmarks/proxy_management_benchmark.cpp @@ -9,7 +9,7 @@ #include -#include "proxy.h" +#include namespace { diff --git a/docs/PRO_DEF_FREE_AS_MEM_DISPATCH.md b/docs/PRO_DEF_FREE_AS_MEM_DISPATCH.md index d2fb494f..75772271 100644 --- a/docs/PRO_DEF_FREE_AS_MEM_DISPATCH.md +++ b/docs/PRO_DEF_FREE_AS_MEM_DISPATCH.md @@ -51,7 +51,7 @@ struct dispatch_name { #include #include -#include "proxy.h" +#include PRO_DEF_FREE_AS_MEM_DISPATCH(FreeToString, std::to_string, ToString); diff --git a/docs/PRO_DEF_FREE_DISPATCH.md b/docs/PRO_DEF_FREE_DISPATCH.md index c65ecc81..ad02a16f 100644 --- a/docs/PRO_DEF_FREE_DISPATCH.md +++ b/docs/PRO_DEF_FREE_DISPATCH.md @@ -49,7 +49,7 @@ struct dispatch_name { #include #include -#include "proxy.h" +#include PRO_DEF_FREE_DISPATCH(FreeToString, std::to_string, ToString); diff --git a/docs/PRO_DEF_MEM_DISPATCH.md b/docs/PRO_DEF_MEM_DISPATCH.md index 55f3641b..9a86326a 100644 --- a/docs/PRO_DEF_MEM_DISPATCH.md +++ b/docs/PRO_DEF_MEM_DISPATCH.md @@ -52,7 +52,7 @@ struct dispatch_name { #include #include -#include "proxy.h" +#include PRO_DEF_MEM_DISPATCH(MemAt, at); diff --git a/docs/access_proxy.md b/docs/access_proxy.md index 0d1bfe6d..0a39823c 100644 --- a/docs/access_proxy.md +++ b/docs/access_proxy.md @@ -33,7 +33,7 @@ Similar to [`proxy_invoke`](proxy_invoke.md), this function can be used to imple #include #include -#include "proxy.h" +#include PRO_DEF_FREE_DISPATCH(FreeToString, std::to_string, ToString); diff --git a/docs/allocate_proxy.md b/docs/allocate_proxy.md index cb9a911d..1e2f70ec 100644 --- a/docs/allocate_proxy.md +++ b/docs/allocate_proxy.md @@ -41,7 +41,7 @@ The implementation of `allocated-ptr` may vary depending on the definition of `F ```cpp #include -#include "proxy.h" +#include // By default, the maximum pointer size defined by pro::facade_builder // is 2 * sizeof(void*). This value can be overridden by `restrict_layout`. diff --git a/docs/allocate_proxy_shared.md b/docs/allocate_proxy_shared.md index 14e8f4ff..4d2f0ca7 100644 --- a/docs/allocate_proxy_shared.md +++ b/docs/allocate_proxy_shared.md @@ -42,7 +42,7 @@ The implementation of `strong-compact-ptr` may vary depending on the definition #include #include -#include "proxy.h" +#include struct RttiAware : pro::facade_builder ::support_copy diff --git a/docs/basic_facade_builder.md b/docs/basic_facade_builder.md index 8042f538..f6c8a574 100644 --- a/docs/basic_facade_builder.md +++ b/docs/basic_facade_builder.md @@ -115,7 +115,7 @@ struct CopyableCallable : pro::facade_builder ```cpp #include -#include "proxy.h" +#include template struct MovableCallable : pro::facade_builder diff --git a/docs/basic_facade_builder/add_convention.md b/docs/basic_facade_builder/add_convention.md index 7aa65c64..33328e55 100644 --- a/docs/basic_facade_builder/add_convention.md +++ b/docs/basic_facade_builder/add_convention.md @@ -38,7 +38,7 @@ Adding duplicated combinations of some dispatch type and overload type is well-d #include #include -#include "proxy.h" +#include PRO_DEF_FREE_DISPATCH(FreeToString, std::to_string, ToString); diff --git a/docs/basic_facade_builder/add_facade.md b/docs/basic_facade_builder/add_facade.md index 0fa12812..6a843bc1 100644 --- a/docs/basic_facade_builder/add_facade.md +++ b/docs/basic_facade_builder/add_facade.md @@ -17,7 +17,7 @@ Adding a facade type that contains duplicated convention or reflection types alr #include #include -#include "proxy.h" +#include PRO_DEF_MEM_DISPATCH(MemSize, size); PRO_DEF_MEM_DISPATCH(MemAt, at); diff --git a/docs/basic_facade_builder/add_reflection.md b/docs/basic_facade_builder/add_reflection.md index 4edc03a8..7a5e99d9 100644 --- a/docs/basic_facade_builder/add_reflection.md +++ b/docs/basic_facade_builder/add_reflection.md @@ -35,7 +35,7 @@ Adding duplicate reflection types is well-defined, whether done directly via `ad #include #include -#include "proxy.h" +#include struct LayoutReflector { public: diff --git a/docs/basic_facade_builder/build.md b/docs/basic_facade_builder/build.md index d365fa0b..75ab53fa 100644 --- a/docs/basic_facade_builder/build.md +++ b/docs/basic_facade_builder/build.md @@ -57,7 +57,7 @@ The default values of the fields of [`proxiable_ptr_constraints`](../proxiable_p ```cpp #include -#include "proxy.h" +#include struct DefaultBase : pro::facade_builder ::build {}; diff --git a/docs/basic_facade_builder/restrict_layout.md b/docs/basic_facade_builder/restrict_layout.md index 3d78fb61..c291d368 100644 --- a/docs/basic_facade_builder/restrict_layout.md +++ b/docs/basic_facade_builder/restrict_layout.md @@ -18,7 +18,7 @@ If no layout restriction is applied before specifying [`build`](build.md), the d #include #include -#include "proxy.h" +#include struct DefaultFacade : pro::facade_builder::build {}; diff --git a/docs/basic_facade_builder/support_copy.md b/docs/basic_facade_builder/support_copy.md index 79a7d508..986a2832 100644 --- a/docs/basic_facade_builder/support_copy.md +++ b/docs/basic_facade_builder/support_copy.md @@ -16,7 +16,7 @@ If no copyability support is applied before specifying [`build`](build.md), the ```cpp #include -#include "proxy.h" +#include struct Movable : pro::facade_builder::build {}; diff --git a/docs/basic_facade_builder/support_destruction.md b/docs/basic_facade_builder/support_destruction.md index 66f705e1..e7387af6 100644 --- a/docs/basic_facade_builder/support_destruction.md +++ b/docs/basic_facade_builder/support_destruction.md @@ -16,7 +16,7 @@ If no destructibility support is applied before specifying [`build`](build.md), ```cpp #include -#include "proxy.h" +#include struct Movable : pro::facade_builder::build {}; diff --git a/docs/basic_facade_builder/support_format.md b/docs/basic_facade_builder/support_format.md index 033360f0..986e3e7b 100644 --- a/docs/basic_facade_builder/support_format.md +++ b/docs/basic_facade_builder/support_format.md @@ -16,7 +16,7 @@ The member types `support_format` and `support_wformat` of `basic_facade_builder #include #include -#include "proxy.h" +#include struct Formattable : pro::facade_builder ::support diff --git a/docs/basic_facade_builder/support_relocation.md b/docs/basic_facade_builder/support_relocation.md index a59cfade..f5f5b7af 100644 --- a/docs/basic_facade_builder/support_relocation.md +++ b/docs/basic_facade_builder/support_relocation.md @@ -16,7 +16,7 @@ If no relocatability support is applied before specifying [`build`](build.md), t ```cpp #include -#include "proxy.h" +#include struct Movable : pro::facade_builder::build {}; diff --git a/docs/basic_facade_builder/support_rtti.md b/docs/basic_facade_builder/support_rtti.md index 10fc61e4..e790019b 100644 --- a/docs/basic_facade_builder/support_rtti.md +++ b/docs/basic_facade_builder/support_rtti.md @@ -22,7 +22,7 @@ The member types `support_rtti`, `support_indirect_rtti` and `support_direct_rtt ```cpp #include -#include "proxy.h" +#include struct RttiAware : pro::facade_builder ::support diff --git a/docs/basic_facade_builder/support_rtti/proxy_cast.md b/docs/basic_facade_builder/support_rtti/proxy_cast.md index 225f16d2..ab3cfd99 100644 --- a/docs/basic_facade_builder/support_rtti/proxy_cast.md +++ b/docs/basic_facade_builder/support_rtti/proxy_cast.md @@ -61,7 +61,7 @@ These functions are not visible to ordinary [unqualified](https://en.cppreferenc ```cpp #include -#include "proxy.h" +#include struct RttiAware : pro::facade_builder ::support diff --git a/docs/basic_facade_builder/support_rtti/proxy_typeid.md b/docs/basic_facade_builder/support_rtti/proxy_typeid.md index 0c14f4ff..f2097409 100644 --- a/docs/basic_facade_builder/support_rtti/proxy_typeid.md +++ b/docs/basic_facade_builder/support_rtti/proxy_typeid.md @@ -20,7 +20,7 @@ These functions are not visible to ordinary [unqualified](https://en.cppreferenc ```cpp #include -#include "proxy.h" +#include struct RttiAware : pro::facade_builder ::support diff --git a/docs/basic_facade_builder/support_view.md b/docs/basic_facade_builder/support_view.md index 0dbcc459..4d3c63aa 100644 --- a/docs/basic_facade_builder/support_view.md +++ b/docs/basic_facade_builder/support_view.md @@ -17,7 +17,7 @@ Let `p` be a value of type `proxy`, `ptr` be the contained value of `p` (if a ```cpp #include -#include "proxy.h" +#include struct RttiAware : pro::facade_builder ::support diff --git a/docs/basic_facade_builder/support_weak.md b/docs/basic_facade_builder/support_weak.md index d7c52b5d..3906bd0a 100644 --- a/docs/basic_facade_builder/support_weak.md +++ b/docs/basic_facade_builder/support_weak.md @@ -17,7 +17,7 @@ Let `p` be a value of type `proxy`, `ptr` of type `P` be the contained value ```cpp #include -#include "proxy.h" +#include struct Formattable : pro::facade_builder ::support diff --git a/docs/explicit_conversion_dispatch.md b/docs/explicit_conversion_dispatch.md index 44072034..ecb159de 100644 --- a/docs/explicit_conversion_dispatch.md +++ b/docs/explicit_conversion_dispatch.md @@ -26,7 +26,7 @@ Class `explicit_conversion_dispatch` models a [dispatch](ProDispatch.md) type fo ```cpp #include -#include "proxy.h" +#include struct IntConvertible : pro::facade_builder ::add_convention diff --git a/docs/facade_aware_overload_t.md b/docs/facade_aware_overload_t.md index 01d4c55c..d99c9e3e 100644 --- a/docs/facade_aware_overload_t.md +++ b/docs/facade_aware_overload_t.md @@ -16,7 +16,7 @@ Class template `facade_aware_overload_t` specifies a facade-aware overload te ```cpp #include -#include "proxy.h" +#include template using BinaryOverload = pro::proxy(const pro::proxy_indirect_accessor& rhs) const; diff --git a/docs/implicit_conversion_dispatch.md b/docs/implicit_conversion_dispatch.md index ae57ffc9..dbaa2a01 100644 --- a/docs/implicit_conversion_dispatch.md +++ b/docs/implicit_conversion_dispatch.md @@ -24,7 +24,7 @@ Class `implicit_conversion_dispatch` models a [dispatch](ProDispatch.md) type fo ```cpp #include -#include "proxy.h" +#include struct Runnable : pro::facade_builder ::add_convention, void()> diff --git a/docs/inplace_proxiable_target.md b/docs/inplace_proxiable_target.md index 22e182ed..a6cfb8db 100644 --- a/docs/inplace_proxiable_target.md +++ b/docs/inplace_proxiable_target.md @@ -12,7 +12,7 @@ See [`make_proxy_inplace`](make_proxy_inplace.md) for the definition of the expo ```cpp #include -#include "proxy.h" +#include // By default, the maximum pointer size defined by pro::facade_builder // is 2 * sizeof(void*). This value can be overridden by `restrict_layout`. diff --git a/docs/make_proxy.md b/docs/make_proxy.md index 07482bd1..da61ac8c 100644 --- a/docs/make_proxy.md +++ b/docs/make_proxy.md @@ -50,7 +50,7 @@ Throws any exception thrown by allocation and the constructor of `T`. #include #include -#include "proxy.h" +#include struct Printable : pro::facade_builder ::add_convention, std::ostream&(std::ostream&) const> diff --git a/docs/make_proxy_inplace.md b/docs/make_proxy_inplace.md index c2143c5c..b622e9b6 100644 --- a/docs/make_proxy_inplace.md +++ b/docs/make_proxy_inplace.md @@ -44,7 +44,7 @@ Throws any exception thrown by the constructor of `T`. ```cpp #include -#include "proxy.h" +#include // By default, the maximum pointer size defined by pro::facade_builder // is 2 * sizeof(void*). This value can be overridden by `restrict_layout`. diff --git a/docs/make_proxy_shared.md b/docs/make_proxy_shared.md index 16315609..6de86946 100644 --- a/docs/make_proxy_shared.md +++ b/docs/make_proxy_shared.md @@ -35,7 +35,7 @@ Throws any exception thrown by allocation and the constructor of `T`. ```cpp #include -#include "proxy.h" +#include struct RttiAware : pro::facade_builder ::support_copy diff --git a/docs/make_proxy_view.md b/docs/make_proxy_view.md index 9316049a..b18b9d26 100644 --- a/docs/make_proxy_view.md +++ b/docs/make_proxy_view.md @@ -20,7 +20,7 @@ The constructed `proxy_view` object. #include #include -#include "proxy.h" +#include PRO_DEF_MEM_DISPATCH(MemAt, at); diff --git a/docs/msft_lib_proxy.md b/docs/msft_lib_proxy.md index 9b8836c3..4f642c1e 100644 --- a/docs/msft_lib_proxy.md +++ b/docs/msft_lib_proxy.md @@ -19,7 +19,7 @@ Similar to the standard [feature test macros](https://en.cppreference.com/w/cpp/ ```cpp #include -#include "proxy.h" +#include int main() { #if defined(__msft_lib_proxy) && __msft_lib_proxy >= 202408L diff --git a/docs/operator_dispatch.md b/docs/operator_dispatch.md index 52114d4e..1db33def 100644 --- a/docs/operator_dispatch.md +++ b/docs/operator_dispatch.md @@ -120,7 +120,7 @@ Let `self` be the operand of [`proxy`](proxy.md), and `other` and `others...` be #include #include -#include "proxy.h" +#include struct Number : pro::facade_builder ::add_convention, void(int)> diff --git a/docs/proxiable.md b/docs/proxiable.md index 70bcb12f..33237d0b 100644 --- a/docs/proxiable.md +++ b/docs/proxiable.md @@ -13,7 +13,7 @@ The concept `proxiable` specifies that [`proxy`](proxy.md) can potentia #include #include -#include "proxy.h" +#include PRO_DEF_FREE_DISPATCH(FreeToString, std::to_string, ToString); diff --git a/docs/proxiable_target.md b/docs/proxiable_target.md index c077c28a..444b7adc 100644 --- a/docs/proxiable_target.md +++ b/docs/proxiable_target.md @@ -10,7 +10,7 @@ See [`make_proxy_view`](make_proxy_view.md) for the definition of the exposition ## Example ```cpp -#include "proxy.h" +#include struct Runnable : pro::facade_builder ::add_convention, void()> diff --git a/docs/proxy.md b/docs/proxy.md index 8bd176bc..2be0bcad 100644 --- a/docs/proxy.md +++ b/docs/proxy.md @@ -54,7 +54,7 @@ Another major difference is that `proxy` is open to abstractions. Unlike `std::f #include #include -#include "proxy.h" +#include PRO_DEF_MEM_DISPATCH(MemAt, at); diff --git a/docs/proxy/constructor.md b/docs/proxy/constructor.md index d3f1df2c..523d4f53 100644 --- a/docs/proxy/constructor.md +++ b/docs/proxy/constructor.md @@ -85,7 +85,7 @@ The constructors of `proxy` are similar to but have certain differences from #include #include -#include "proxy.h" +#include PRO_DEF_MEM_DISPATCH(MemSize, size); PRO_DEF_MEM_DISPATCH(MemClear, clear); diff --git a/docs/proxy/destructor.md b/docs/proxy/destructor.md index 2e85df2e..08066a3a 100644 --- a/docs/proxy/destructor.md +++ b/docs/proxy/destructor.md @@ -15,7 +15,7 @@ Destroys the `proxy` object. If the `proxy` contains a value, the contained valu ```cpp #include -#include "proxy.h" +#include struct AnyMovable : pro::facade_builder::build {}; diff --git a/docs/proxy/emplace.md b/docs/proxy/emplace.md index 3225528e..ef98f205 100644 --- a/docs/proxy/emplace.md +++ b/docs/proxy/emplace.md @@ -47,7 +47,7 @@ Similar to [`std::any::emplace`](https://en.cppreference.com/w/cpp/utility/any/e #include #include -#include "proxy.h" +#include struct AnyCopyable : pro::facade_builder ::support_copy diff --git a/docs/proxy/friend_operator_equality.md b/docs/proxy/friend_operator_equality.md index 0e281abc..e4b7e0a5 100644 --- a/docs/proxy/friend_operator_equality.md +++ b/docs/proxy/friend_operator_equality.md @@ -19,7 +19,7 @@ The `!=` operator is [synthesized](https://en.cppreference.com/w/cpp/language/de ```cpp #include -#include "proxy.h" +#include struct AnyMovable : pro::facade_builder::build {}; diff --git a/docs/proxy/friend_swap.md b/docs/proxy/friend_swap.md index 637dbcc3..ee5c1e16 100644 --- a/docs/proxy/friend_swap.md +++ b/docs/proxy/friend_swap.md @@ -15,7 +15,7 @@ This function is not visible to ordinary [unqualified](https://en.cppreference.c #include #include -#include "proxy.h" +#include PRO_DEF_FREE_DISPATCH(FreeToString, std::to_string, ToString); diff --git a/docs/proxy/indirection.md b/docs/proxy/indirection.md index c2160557..fb6ae42d 100644 --- a/docs/proxy/indirection.md +++ b/docs/proxy/indirection.md @@ -38,7 +38,7 @@ These operators do not check whether the `proxy` contains a value. To check whet #include #include -#include "proxy.h" +#include PRO_DEF_MEM_DISPATCH(MemSize, size); diff --git a/docs/proxy/operator_bool.md b/docs/proxy/operator_bool.md index d5409afb..b7507c04 100644 --- a/docs/proxy/operator_bool.md +++ b/docs/proxy/operator_bool.md @@ -16,7 +16,7 @@ Checks whether `*this` contains a value. ```cpp #include -#include "proxy.h" +#include struct AnyMovable : pro::facade_builder::build {}; diff --git a/docs/proxy/reset.md b/docs/proxy/reset.md index fedd8af7..0d867832 100644 --- a/docs/proxy/reset.md +++ b/docs/proxy/reset.md @@ -13,7 +13,7 @@ Destroys the contained value if it exists. After the call, `*this` does not cont ```cpp #include -#include "proxy.h" +#include struct AnyMovable : pro::facade_builder::build {}; diff --git a/docs/proxy_invoke.md b/docs/proxy_invoke.md index 61ea063e..0ae4ba11 100644 --- a/docs/proxy_invoke.md +++ b/docs/proxy_invoke.md @@ -45,7 +45,7 @@ It is generally not recommended to call `proxy_invoke` directly. Using an [`acce #include #include -#include "proxy.h" +#include PRO_DEF_FREE_DISPATCH(FreeToString, std::to_string, ToString); diff --git a/docs/proxy_reflect.md b/docs/proxy_reflect.md index 6e08849f..a1ae872c 100644 --- a/docs/proxy_reflect.md +++ b/docs/proxy_reflect.md @@ -20,7 +20,7 @@ This function is useful when only metadata deduced from a type is needed. While #include #include -#include "proxy.h" +#include class CopyabilityReflector { public: diff --git a/docs/proxy_view.md b/docs/proxy_view.md index be7e1292..a1dad95a 100644 --- a/docs/proxy_view.md +++ b/docs/proxy_view.md @@ -28,7 +28,7 @@ Class template `observer_facade` is a [facade](facade.md) type for observer poin ```cpp #include -#include "proxy.h" +#include template struct FMap : pro::facade_builder diff --git a/docs/weak_dispatch.md b/docs/weak_dispatch.md index 8e7cdf77..0633b5bb 100644 --- a/docs/weak_dispatch.md +++ b/docs/weak_dispatch.md @@ -28,7 +28,7 @@ In [Java](https://docs.oracle.com/javase/specs/jls/se23/html/jls-9.html#jls-9.4- #include #include -#include "proxy.h" +#include PRO_DEF_MEM_DISPATCH(MemAt, at); diff --git a/docs/weak_proxy.md b/docs/weak_proxy.md index 9c42e478..4de50c89 100644 --- a/docs/weak_proxy.md +++ b/docs/weak_proxy.md @@ -28,7 +28,7 @@ Class template `weak_facade` is a [facade](facade.md) type for weak pointers (e. ```cpp #include -#include "proxy.h" +#include struct Formattable : pro::facade_builder ::support diff --git a/include/proxy/details/proxy_impl.h b/include/proxy/details/proxy_impl.h new file mode 100644 index 00000000..31198683 --- /dev/null +++ b/include/proxy/details/proxy_impl.h @@ -0,0 +1,2513 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#ifndef _MSFT_PROXY_ +#define _MSFT_PROXY_ + +#include "proxy_impl_macros.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if __STDC_HOSTED__ +#include +#if __has_include() +#include +#endif // __has_include() +#endif // __STDC_HOSTED__ + +#if __cpp_rtti >= 199711L +#include +#include +#endif // __cpp_rtti >= 199711L + +namespace pro { + +namespace details { + +struct applicable_traits { + static constexpr bool applicable = true; +}; +struct inapplicable_traits { + static constexpr bool applicable = false; +}; + +template